views:

19

answers:

1

Hi,

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";
A: 

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);
Brad F Jacobs
thanks Brad, that saved me a lot of time, Think you are right regarding gmail reply to. Think he will just have to live with it.
Roscoeh