开发者

Question about Unsuccessful delivery reports in sending bulk Emails

开发者 https://www.devze.com 2023-03-01 16:39 出处:网络
I have database of approximately 10k users who have subscribed for newsletters. I am changing my site from asp to php. I am sending newsletters by cron job. I want to track the record of unsuccessful

I have database of approximately 10k users who have subscribed for newsletters. I am changing my site from asp to php. I am sending newsletters by cron job. I want to track the record of unsuccessful delivery report. How is it possible? Please Guide me开发者_如何学编程, Thanks.


In php when you sending mail with mail function you should check with condition

if(mail($to, $subject, $message, $headers)){ // Successfull mail delivery } else { // Code for un-successfull mailing }

This is highly inaccruate for what the OP is actually trying to do... From the manual:

It is important to note that just because the mail was accepted for delivery, it does NOT mean the mail will actually reach the intended destination.

Depending on server type and configuration you will get varying results. Its better to use SMTP to ensure a proper and consistent interface. Generally i would use a library to do this... you could do it yourself manually using sockets, but why reinvent the wheel? There are 3 libraries i use depending on the project...

  • SwiftMailer
  • Zend_Mail
  • PHPMailer

For this level of interaction i would use SwiftMailer or Zend_Mail. Both of these support getting information from SMTP as well as sending the message, so for example you can get info about failed recipients (SwitftMailer example). Both Zend and Swift also support custom spools queues so you can more deeply integrate queuing and sending messages in an application aware way. SwiftMailer also has batchSend functionality... i assume this is available in Zend_Mail as well but ive never dug in to deep.

This is only half the battle though... In order to actually read the NDR's you need to script logging in to the mail store, looping through the messages, and then parsing the headers and/or the message body of the NDR (make sure you refer to the RFC docs listed on the wikipage), then take action based on that. Recently i used Zend_Mail_Storage to handle this. If you need to do this then you probably also want to just go ahead and use Zend_Mail for sending as well since Storage is included in the component. Youll need to take a look at the RFC for NDR's and status codes in order to parse properly.

Overall, if at all possible, i recommend just integrating a 3rd party service like MailChimp or Constant Contact. Its a a lot less work, and unless you have a team of devs working on this over time a service is probably going to yield better results across the board.


In php when you sending mail with mail function you should check with condition

if(mail($to, $subject, $message, $headers)){ // Successfull mail delivery } else { // Code for un-successfull mailing }

0

精彩评论

暂无评论...
验证码 换一张
取 消