質問

I'm sending newsletter using Zend Mail. I have used setReturnPath() to put all undelivered mail notifications in one place.

And what now?

  • How to get the list of addresses which were unreachable?
  • How do I read and parse the returned notifications?
  • How to know whether the mail returned because of non existing email or just quota exceeded?
  • Which headers do I need to send and check?

Related:

役に立ちましたか?

解決

This class may be helpful. Can determine whether the mail is a bounce and return a response code with description:

他のヒント

Short Answer:

you can't do that in a simple way and not in your app.

Long Answer:

You should handle that in asynchronous way and outside your php app (at least in part). First of all you must setup the return address to something like sender+recipient=recipientdomain.com@senderdomain.com as in the TimB answer. At this point all the notification sent by receiving smtp server will go to that address.

Then you need to setup the smtp daemon at senderdomain.com mail exchanger to handle that kind of bounce messages and process them in some sort of pipe.

With a pipe you can forward the returned message to an external program which parse the message and extract the needed informations (i.e. the reason why the delivery is failed)

At that point in your program (which can be a cli script in your application) you can mark the address as failing and optionally can record why.

This is a pretty difficult task, which can't be handled in a simple application. Usually I use a dedicated software for large mailing list handling such as sympa which takes care of this task for you.

Otherwise you can use an external delivery service such as Sendgrid which will do the dirty job for you and report the failing addresses with a simple API. As a bonus with this solution, they are in the whitelists for all the major providers, so your email won't be marked as spam as far as you respect some simple rules (i.e. removing bouncing addresses and use an opt-in policy for your newsletter)

Well, the second link and especially the answer by TimB explains very well the procedure.

What may not be clear is that the return path is nothing other than a regular email account, i.e. you will get the email to that address. Zend_Mail is not waiting for a response and hence there is no list of addresses.

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top