phpgmailswiftmaileremail-bounces

Does Gmail not allow sender to set a return path value to receive bounce messages?


I am using Swift Mailer to check for bounced messages. I have created one separate account for bounce messages, however when I set the return path, it does not allow the bounce message send to that account. Is it normal or is it a code error?

$verp = 'bounces-' . str_replace('@', '=', $row['ReplyTo']) . '@gmail.com';

$message = Swift_Message::newInstance()
  ->setSubject($row['Subject'])
  ->setFrom(array($row['ReplyTo'] => $row['FromName']))
  ->setReturnPath($verp)
  ->setBody($html, 'text/html')
  ->addPart($txt, 'text/plain');

I am now using VERP, it seems that it is to locate a delivery error? But not for sending the message to a bounce mail account?


Solution

  • Yes, that is normal. When sending email through Gmail's SMTP servers, it will force the return-path to be the account you are sending from.

    Your only solution is to search for a provider which allows you to set the return-path.