2WFR
2WFR

Reputation: 145

PHPMailer bounce email address shows in sender mailbox

I am using a PHP script to send emails using PHPMailer (on an ovh web server).

      $mail->isMail();
      ......
      $mail->addReplyTo('[email protected]', 'Site');
      $mail->SetFrom('[email protected]', 'Site');

Emails get delivered to my gmail account BUT not to other addresses (e.g. my Business email).

      $mail->isMail();
      ......
      $mail->addReplyTo('[email protected]', 'Site');
      $mail->Sender = '[email protected]';

Emails get delivered to other addresses (e.g. my Business email) BUT not to gmail.

Also the sender appears as bounce-id=D004=U58180. …… .net

which is not so friendly.

Is there a way to solve those issues ?

Upvotes: 0

Views: 127

Answers (1)

Synchro
Synchro

Reputation: 37700

Using setFrom by itself will result in Sender being set to the same value as your from address (look at the code in the setFrom method). So in your second example you're setting the envelope sender, but not the from address, which is likely not what you want.

You may find it easier to use SMTP to localhost instead of isMail(); just changing that method to isSMTP() should be enough to do that. That way you can set SMTPDebug = 2 and see exactly what your local mail server is saying.

Separately, you don't need to set a reply-to address if it's the same as your from address – PHPMailer will simply ignore it if you try to set them to the same value anyway.

Upvotes: 1

Related Questions