Jump to content

Recommended Posts

We're running a foreclosure bid service that sends a lot of email status notifications. (ie bid received, high number, outbid, sale results etc)

 

Most days it works great. However, occasionally, there are a handful of emails that people claim they never got. I have a log file I write to immediately after the mail function. It is not conditioned on the return var... it just writes the mail vars to the log. So according to the log it APPEARS that all the emails were sent.

 

I've asked the host to check if there are any smtp errors. He says he doesn't see any.

 

So..... is there a best practice for attempting to send again on failure?

 

Should I just try a few times if it returns false?

Should I write it all to the db, use a pending/success flag and cron to work through the pendings? That way it continues to attempt failures and I can run a failure report.

 

I don't know. Any bright ideas?

 

 

Once you add the mail function returned status to the logged information, you will be able to determine if you can do anything on the php/sending side.

 

The php mail function only returns the status that the sending mail server passes back to it at the time the email is given to your sending mail server. That's the end of php's involvement in the process. The status basically means that your sending mail server accepted the email from your php script. It does not mean that the mail server will even attempt to send it or that it was actually sent or that it was successfully received.

 

About the only thing that comes to mind that you can do is to put a valid email address into the Return-path: mail header and then check that mail box for messages sent back from the receiving mail servers.

 

 

Thanks for the input.

I like the idea of the return-path. Hadn't considered that it might return delivery failure errors.

 

So...

I'm going to add a return-path header.

Grab the return var and make three attempts on error with a small sleep() in between. (anything wrong with this?)

Write the failed mail vars to a log file and/or mail the errors to me so at least I can run interference on failure.

 

In theory, doing this... I would know if the mail function failed to pass the vars to smtp and be able to distinguish that from a delivery failure.

 

Am I correct in my assumptions?

If calling mail() fails, repeatedly doing it will likely also fail. Typical error messages are  - invalid/missing/malformed address, authentication required/relaying attempt, no sending mail server (it's down or off), blacklisted addresses/domains,...

 

If you have php's error_reporting set to E_ALL and log_errors set to ON, any returned error message will get logged to the error log file. You can also use error_get_last (php5.2 or higher) or $php_errormsg (if you set track_errors first) to get any error message that is produced when the mail() call fails.

 

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.