Forum Moderators: coopster

Message Too Old, No Replies

multiple mail() calls, only 1 email sent

sending multiple emails

         

filemakerguy

9:07 pm on May 9, 2008 (gmt 0)

10+ Year Member



Last night I setup a php script to send multiple emails. The problem is when 2 mail() calls occur only 1 email is received. And its never the same email recieved, its random, sometimes email 1, sometimes email 2 is recieved.

The storying behind why multiple emails are being sent. Simple web form processed by php sending the contents via email and also creates a record in a database on a different server.

The second email is sent when an error occurs when interacting with the database. The email is sent to notify the appropriate personnel that the database is down or unable to be reached and the record must be manually added.

While troubleshooting I found some details in the php website user feedback section that modifying the header Message-ID to ensure uniqueness may resolve the problem as some mail servers consolidate messages with the same Message-ID.

Anyone know of a best practice to ensuring multiple mail() calls are always received when sent.

Thank you for your response in advanced.

Kevin

dreamcatcher

12:50 pm on May 13, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Hi Kevin,

Can you give us a snippet of your code? Do you find the e-mails get sent depending on certain addresses used? Any specific patterns?

dc

eelixduppy

4:05 pm on May 13, 2008 (gmt 0)



I'm assuming that these emails are being sent to two different email addresses? Try sending both emails to two completely different email addresses if you aren't already, to see if you are still having the same problem. For instance test@example.com and test@example2.com. If they are only receiving one then you know the problem probably isn't with the servers receiving the emails, but your script or your SMTP server screwing something up along the way.

filemakerguy

6:18 am on May 15, 2008 (gmt 0)

10+ Year Member



Actually the emails are being sent to the same email address. One is the content of the form being submitted, then the database record is inserted, if it fails the second email is sent to the same person noting the error.

The emails are being sent from one web host to another web host where the emails are received. I suspect the emails have the same message id's (not sure why) and the mail server just accepts one of them. Which ever arrives first maybe, I'm guessing its a matter of milliseconds.

I did modify the header on the second email to force a unique Message ID and it resolved the problem, but I believe there has to be a better way to ensure robustness.

Thank you for your feedback and wisdom in advance