"; require_once('class.phpmailer.php'); //***include("class.smtp.php"); // optional, gets called from within class.phpmailer.php if not already loaded $mto=$_POST['recipient']; $mfrom=$_POST['email']; $mto=$mto . "@" . $ppage[0]; $subject=$_POST['subject']; // Check Validate email $perror==''; if (!preg_match("/^([a-zA-Z0-9])(.)+@([a-zA-Z0-9_-])+(\.[a-zA-Z0-9_-]+)+/", $mto)) { $perror="The email address you are sending to is not valid"; header("location:" . $retpage . "?perror=" . $perror); } //if (!preg_match("/^([a-zA-Z0-9])(.)+@([a-zA-Z0-9_-])+(\.[a-zA-Z0-9_-]+)+/", $mfrom)) { //$perror="The email address you are sending from is not valid"; //header("location:$retpage?perror=" . $perror); //} //if(!filter_input(INPUT_POST, "recipient", FILTER_VALIDATE_EMAIL)) { //header("location:mcheck.php?perror=The email address you are sending to is not valid"); //} //******************* $mail = new PHPMailer(true); // the true param means it will throw exceptions on errors, which we need to catch $mail->IsHTML(true); $mail->IsSMTP(); // telling the class to use SMTP //try{ //$mail->SMTPDebug = 2; // enables SMTP debug information (for testing) $mail->SMTPAuth = false; // enable SMTP authentication $mail->Host = "mail2.palmsecure.biz"; // sets the SMTP server $mail->Port = 25; // set the SMTP port for the GMAIL server $mail->AddAddress($mto); // $mail->AddReplyTo('name@yourdomain.com', 'First Last'); $mail->AddAddress($mto); $mail->WordWrap = 150; // $mail->AddCC('julia@southonline.co.uk', 'John Doe'); $sql=("SELECT username, passwd FROM maildb WHERE username='$mto'"); $result=mysql_query($sql); $count=mysql_num_rows($result); if ($count>0) { $filename = $_POST['filename']; //this is the filename input of your form $limit_size=2000000; //if ($_FILES['filename']['size']>1000000) //echo "To Large"; //} $file = basename($_FILES['filename']['name']); if($file>'') { $file_size=$HTTP_POST_FILES['filename']['size']; if($file_size >= $limit_size){ $perror="You file is over the 2MB limit!"; header("location:" . $retpage . "?perror=" . $perror); } $uploaddir = 'uploads/'; //where you want the file to go $file = stripslashes($file); // Check file extension $allowed_filetypes = array('.txt','.csv','.htm','.html','.xml','.css','.doc','.xls','.rtf','.pdf','.jpg','.jpeg','.gif','.png'); $ext = substr($file, strpos($file,'.'), strlen($file)-1); if(in_array($ext,$allowed_filetypes)){ } else { $perror="You may only send the following file extensions - txt, csv, htm, html, xml, css, doc, xls, rtf, pdf, jpg, jpeg, gif, png"; header("location:" . $retpage . "?perror=" . $perror); } ////////////////// $uploadfile = $uploaddir . $file; //the move_uploaded_file() function is what moves the temp working file to it's final location. if (move_uploaded_file($_FILES['filename']['tmp_name'], $uploadfile)) { // echo "
"; 
// echo "Successfully Uploaded: $file...\n"; 
		$mail->AddAttachment('uploads/' . $file);
		} else { 
//$perror="Your email was sent but the file attachment failed.";
//header("location:" . $retpage . "?perror=" . $perror);
echo "
"; 
 echo "upload failed!\n"; 
 echo 'Here is some more info on your upload:'; 
 print_r($file); 
 echo "
"; } } $info=mysql_fetch_array($result); //$mail->Username = $mto; // SMTP account username //$mail->Password = $info['passwd']; // SMTP account password $mail->SetFrom($mfrom); // $mail->AddReplyTo('name@yourdomain.com', 'First Last'); $mail->Subject = $subject; $body = ""; foreach($_POST as $name => $value) { if ($name=="recipient" || $name=="email" || $name=="subject" || $name=="Submit" || $name=="redirect" || $name=="image") { //$body .= "\n"; } else { $body .= ""; } } $body .='
$name: " . str_replace("\n","
",$value) . "




To view the message, please use an HTML compatible email viewer!'; $mail->MsgHTML($body) ; // optional - MsgHTML will create an alternate automatically // $mail->MsgHTML(file_get_contents('contents.html')); // $mail->AddAttachment('images/phpmailer.gif'); // attachment //$mail->AddAttachment('images/1bar.jpg'); // attachment $mail->Send(); unlink('uploads/' . $file); //header("location:" . $_POST['redirect'] ); } else { $perror="The email address you are sending to is not valid"; header("location:" . $retpage . "?perror=" . $perror); } //if(!$mail->Send()) { //echo "Mailer Error: " . $mail->ErrorInfo; //} else { //echo "Message sent!"; //} ?>