How to check if an e-mail bounced when sent using the mail() function?
NeedExpertHelp
9:02 pm on Aug 7, 2010 (gmt 0)
Hi,
How can you check if an e-mail bounced when sent using the mail() function?
In other words, how can I check if I got one of those MAIL DELIVERY SUBSYSTEM failures in PHP (e.g. due to the recipient e-mail not existing) ?
Thanks!
Matthew1980
6:19 pm on Aug 8, 2010 (gmt 0)
Hi there NeedExpertHelp,
I think as this is an inherent problem with the mail function, it only returns a bool when the function is actioned, so theoritically:-
if(mail(....yourParameters...)){ //Success message as message sent } else{ //Message failed in sending }
would be the only way of dealing with a sent/not sent scenario (If anyone can correct me please do as this is what I have always understood this to be)
And the only real test of success is when you check the recipients inbox.
Sorry I can't answer any more fully that that, there may be class's (such as phpmailer that can do this, though I haven't tried this yet) out there that can handle this situation.
Cheers, MRb
enigma1
6:30 pm on Aug 8, 2010 (gmt 0)
There are switches for the headers you set using the mail. -f and -r For example try:
-fsendfrom@example.com -rbounceto@example.com
as the forth argument to the mail function and the format is subject to the mail server. For linux it should typically work like the example above. So the bounceto@example.com should receive the bounced e-mails.