I am trying to add a reply to address to my php mailer and it just puts from "me" and replies to my address.
Any ideas what I am doing wrong? I have added the $mail->AddReplyTo. I want it 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 = "[email protected]"; // GMAIL username
$mail->Password = "xxxxx";
$mail->AddReplyTo($email, $name);
$address = "xxxx.net";
$mail->AddAddress($address, "Contact form");
$mail->Subject = " Contact Form";
PHPMailer does not set any limits, nor does the mail() function, it's only ISPs like GoDaddy that do. However, they do so by blocking access to normal SMTP ports, and/or redirecting SMTP connections to their own servers ( *. secureserver. * ).
usually this happens because the sending server is already marked as spam by somebody. The way i found is go to the gmail account mark the item as 'important' in gmail and 'Add to Safe senders' in Outlook. Save this answer. Show activity on this post.
The way you have setup your PHPMailer, it would require an SMTP server running on your localhost to send the messages. If you don't have an SMTP server running on your localhost, then you can use an external SMTP server to relay the messages through.
Something to try is to make sure your $email
and $name
variables are being passed in correctly (add some debugging statements to echo them out). Not sure if you have done that or if you are checking if the form has posted or not. But that would be step one.
From my workings with PHPMailer and GMail, they do not work to well. Instead I would suggest trying the phpGMailer script. It works great for GMail. See if that does not fix your issues.
UPDATE
Thinking about it, I do not think GMail permits the changing of the ReplyTo
address unless the GMail account has activated authorization for that account. I am not 100% sure on this, but I know through the web interface that is not possible.
Off Topic
I would avoid using eregi_replace
it is depreciated. I would use preg_replace
instead. Here is an 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);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With