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

£可爱£侵袭症+ 提交于 2019-12-12 12:23:38

问题


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?


回答1:


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.




回答2:


It's not a gmail issue, it's a requirement of the SMTP specification, as defined in RFC 5321 section 4.4:

A message-originating SMTP system SHOULD NOT send a message that already contains a Return-path header field.

It also says that while SMTP systems should not inspect message content at all (i.e. they don't look at headers), a gateway from some other context to SMTP SHOULD remove any return-path header. In short, if you're adding a return-path header yourself, you're doing it wrong.

The return-path header you see in a received message is created by the receiver, not the sender, and is derived from the SMTP MAIL FROM command used to deliver the message. This address need not to have anything in common with the From address header within the message, and designates where the message should be sent to in the event of a delivery failure, i.e. exactly what you want the VERP address for.

I don't know about SwiftMailer, but in PHPMailer you can set the SMTP envelope sender value by setting the Sender property, and a receiver will convert that into a return-path message header on reception.



来源:https://stackoverflow.com/questions/9925392/does-gmail-not-allow-sender-to-set-a-return-path-value-to-receive-bounce-message

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!