Phpmailer cannot add response to address

I am trying to add a response to the address of my php mailer, and it just fits in from "I" and responds to my address.

Any ideas what I'm doing wrong? I added $ mail-> AddReplyTo. I want him to reply to the sender of the web form.

$name = $_POST['name']; $telephone = $_POST['telephone']; $email = $_POST['email']; $message = $_POST['message']; $body = file_get_contents('phpmailer/contents.html'); $body = eregi_replace("[\]",'',$body); $body = eregi_replace("<name>", $name,$body); $body = eregi_replace("<telephone>", $telephone, $body); $body = eregi_replace("<email>", $email, $body); $body = eregi_replace("<message>", $message, $body); $mail->IsSMTP(); // telling the class to use SMTP $mail->Host = "smtp.gmail.com"; // SMTP server // enables SMTP debug information (for testing) // 1 = errors and messages // 2 = messages only $mail->SMTPAuth = true; // enable SMTP authentication $mail->SMTPSecure = "ssl"; // sets the prefix to the servier $mail->Host = "smtp.gmail.com"; // sets GMAIL as the SMTP server $mail->Port = 465; // set the SMTP port for the GMAIL server $mail->Username = "xxx@xxx.net"; // GMAIL username $mail->Password = "xxxxx"; $mail->AddReplyTo($email, $name); $address = "xxxx.net"; $mail->AddAddress($address, "Contact form"); $mail->Subject = " Contact Form"; 
+7
php phpmailer
source share
1 answer

Try something to make sure your $email and $name variables are passed correctly (add some debug statements to print them). Not sure if you did this or if you are checking if the form has been posted or not. But this will be the first step.

From my work with PHPMailer and GMail they do not work well. Instead, I would suggest trying the phpGMailer script. It is great for GMail. See if this fixes your problems.

UPDATE

Thinking about this, I don’t think GMail allows a ReplyTo address ReplyTo if the GMail account has not activated authorization for this account. I am not 100% sure, but I know through the web interface that this is not possible.

Off topic

I would avoid using eregi_replace , it depreciated. Instead, I would use preg_replace . Here is the updated version so you can update your code:

 $body = file_get_contents('phpmailer/contents.html'); $body = preg_replace("~[\]~",'',$body); $body = preg_replace("~<name>~i", $name,$body); $body = preg_replace("~<telephone>~i", $telephone, $body); $body = preg_replace("~<email>~i", $email, $body); $body = preg_replace("~<message>~i", $message, $body); 
+2
source share

All Articles