Hello everyone, can anyone take a look at this script, it's not sending any email.... <?php //Bring in the PHPMailer class require("class.phpmailer.php"); //Create a new mail object. You'll get an error here is the right files are not required //at the top of this script. $mail = new phpmailer(); // set mailer to use SMTP $mail->IsSMTP(); //Specify the use of the local server. //Should not have to authenticate. //If you get an error sending, use the Christian-Web-Masters.com forums to ask //How to change this script to use another server. //Or read the documentation for PHPMailer. $mail->Host = "smtp.mydomain.com"; // ----------------------------------------- // The Web Help .com // ----------------------------------------- // remember to replace you@email.com with your own email address lower in this code. // load the variables form address bar $to = $_REQUEST["to"]; $to = preg_replace("/[^a-zA-Z0-9@._-]/", "", $to); $to = explode(",",$to); $to = $to['0']; // remove the backslashes that normally appears when entering " or ' $to = stripslashes($to); $message = stripslashes($message); $subject = stripslashes($subject); $sendname = stripslashes($sendname); $from = stripslashes($from); // check to see if verificaton code was correct if(md5($verif_box).'a4xn' == $_COOKIE['tntcon']){ // if verification code was correct send the message and show this page $mail->From = $_POST['from']; $mail->FromName = $_POST['sendname']; $mail->AddAddress = $_POST['to']; $mail->Subject = $_POST['subject'] . $subject; $mail->Body = $_POST['message'] . "\r\n" . $_POST['message'] . "\n\n" . $defaultMessageClose; // delete the cookie so it cannot sent again by refreshing this page setcookie('tntcon',''); } else { // if verification code was incorrect then return to contact page and show error header("Location:http://www.mydomain.com/?wrong_code=true"); exit; } ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> <title>E-Mail Sent</title> <style type="text/css"> <!-- body,td,th { font-family: Arial, Helvetica, sans-serif; font-size: 12px; } --> </style></head> <body> Email sent. Thank you.<br /> <br /> Return to <a href="/">home page</a> ? </body> </html> PHP: This script use SMTP and after I input all the detail and click send, somehow this line executed Email sent. Thank you. but i'm not receiving any email in my inbox... This script use some spam filter (regex??) and captchas. Please help me and thanks in advance
$mail->Send() is missing... that's the part that actually sends it. And besides, you're doing weird (unnecessary) stuff with your $to variable: // Removes all commas (if you actually escaped the period) $to = preg_replace("/[^a-zA-Z0-9@._-]/", "", $to); // Exploding the string on non-existent commas. $to = explode(",",$to); $to = $to['0']; // Stripping slashes from non-existent quotes... $to = stripslashes($to); PHP:
I add the $mail->Send() it's still not working <?php //Bring in the PHPMailer class require("class.phpmailer.php"); //Create a new mail object. You'll get an error here is the right files are not required //at the top of this script. $mail = new phpmailer(); // set mailer to use SMTP $mail->IsSMTP(); //Specify the use of the local server. //Should not have to authenticate. //If you get an error sending, use the Christian-Web-Masters.com forums to ask //How to change this script to use another server. //Or read the documentation for PHPMailer. $mail->Host = "localhost"; // ----------------------------------------- // The Web Help .com // ----------------------------------------- // load the variables form address bar $to = $_REQUEST["to"]; $to = preg_replace("/[^a-zA-Z0-9@._-]/", "", $to); $to = explode(",",$to); $to = $to['0']; // remove the backslashes that normally appears when entering " or ' $to = stripslashes($to); $message = stripslashes($message); $subject = stripslashes($subject); $sendname = stripslashes($sendname); $from = stripslashes($from); // check to see if verificaton code was correct if(md5($verif_box).'a4xn' == $_COOKIE['tntcon']){ // if verification code was correct send the message and show this page $mail->From = $_POST['from']; $mail->FromName = $_POST['sendname']; $mail->AddAddress = $_POST['to']; $mail->Subject = $_POST['subject'] . $subject; $mail->Body = $_POST['message'] . "\r\n" . $_POST['message'] . "\n\n" . $mail->Send() $defaultMessageClose; // delete the cookie so it cannot sent again by refreshing this page setcookie('tntcon',''); } else { // if verification code was incorrect then return to contact page and show error header("Location:http://www.mydomain.com/temp/?wrong_code=true"); exit; } ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> <title>E-Mail Sent</title> <style type="text/css"> <!-- body,td,th { font-family: Arial, Helvetica, sans-serif; font-size: 12px; } --> </style></head> <body> Email sent. Thank you.<br /> <br /> Return to <a href="/">home page</a> ? </body> </html> PHP: I get this error now... Parse error: syntax error, unexpected T_STRING in /home/kilot/public_html/mydomain/temp/mailer.php on line 53 Code (markup): Thanks in advance p/s: // load the variables form address bar $to = $_REQUEST["to"]; $to = preg_replace("/[^a-zA-Z0-9@._-]/", "", $to); $to = explode(",",$to); $to = $to['0']; PHP: the code above suppose to prevent any cc and bcc from being executed with the script... afaik
Hello, I change it like you said and this line executed Email sent. Thank you. Return to home page ? Code (markup): but I still don't receive the email. Both my inbox and spambox is empty why is that..?? Thank for your help <?php //Bring in the PHPMailer class require("class.phpmailer.php"); //Create a new mail object. You'll get an error here is the right files are not required //at the top of this script. $mail = new phpmailer(); // set mailer to use SMTP $mail->IsSMTP(); //Specify the use of the local server. //Should not have to authenticate. //If you get an error sending, use the Christian-Web-Masters.com forums to ask //How to change this script to use another server. //Or read the documentation for PHPMailer. $mail->Host = "localhost"; // ----------------------------------------- // The Web Help .com // ----------------------------------------- // load the variables form address bar $to = $_REQUEST["to"]; $to = preg_replace("/[^a-zA-Z0-9@._-]/", "", $to); $to = explode(",",$to); $to = $to['0']; // remove the backslashes that normally appears when entering " or ' $to = stripslashes($to); $message = stripslashes($message); $subject = stripslashes($subject); $sendname = stripslashes($sendname); $from = stripslashes($from); // check to see if verificaton code was correct if(md5($verif_box).'a4xn' == $_COOKIE['tntcon']){ // if verification code was correct send the message and show this page $mail->From = $_POST['from']; $mail->FromName = $_POST['sendname']; $mail->AddAddress = $_POST['to']; $mail->Subject = $_POST['subject'] . $subject; $mail->Body = $_POST['message'] . "\r\n" . $_POST['message'] . "\n\n" . $mail->Send(); // delete the cookie so it cannot sent again by refreshing this page setcookie('tntcon',''); } else { // if verification code was incorrect then return to contact page and show error header("Location:http://www.mydomain.com/temp/?wrong_code=true"); exit; } ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> <title>E-Mail Sent</title> <style type="text/css"> <!-- body,td,th { font-family: Arial, Helvetica, sans-serif; font-size: 12px; } --> </style></head> <body> Email sent. Thank you.<br /> <br /> Return to <a href="/">home page</a> ? </body> </html> PHP: