Dizzy Dizzy - 1 month ago 5
Ajax Question

PHP Mailer not sending to recipient, but sending to form filler ok

I have been ripping my hair out trying to resolve this issue and after days of trying it's now time to ask for some help.

Basically I have a form that I have adapted from this script.

Now, the form is functioning almost correctly, just a few tweaks on my part. But when I test the form it sends to the person sending the form, but it does not send to me.

I have checked with the host and everything is functioning on their end, so I see it as a script issue. I'm an absolute novice when it comes to PHP and Javascript, so I'm hoping somebody can assist me in rectifying this issue. I'm not sure whether it is in the

mail.php
, my form page or the
class.phpmailer.php
file.

This is the code in the mail.php file:

$mail->IsSMTP(); // tell the class to use SMTP
$mail->SMTPAuth = true; // enable SMTP authentication
$mail->Port = I used the correct port number here; // set the SMTP server port
//$mail->Host = "mysmtpserverhost"; // SMTP server
//$mail->Username = "me@myemail.com"; // SMTP server username
//$mail->Password = "mypassword"; // SMTP server password
$mail->IsSendmail(); // tell the class to use Sendmail
$mail->addReplyTo("me@myemail.com");
$mail->AltBody = "To view the message, please use an HTML compatible email viewer!"; // optional, comment out and test
$mail->WordWrap = 80; // set word wrap


Thanks in advance

Answer

Replace :

$mail->addReplyTo("me@myemail.com")

To :

$mail->addAddress("me@myemail.com", '');

Difference between those two :

//Set an alternative reply-to address
$mail->addReplyTo('replyto@example.com', 'First Last');
//Set who the message is to be sent to
$mail->addAddress('whoto@example.com', 'John Doe');

This link will be helpful for you.