[FX.php List] How do you handle failed transactional emails?
Leo R. Lundgren
leo at finalresort.org
Fri Mar 21 11:02:58 MDT 2014
Hi,
For simple projects where e-mail is expected to succeed being accepted by the SMTP server and there's basically never a problem with this, I just give it a shot and if it fails I display an error to the user saying "There was a problem delivering your message. Please try again or contact the system administrator if the problem persists". This is the most basic functionality.
Then if you need more than that you can separate out the entire concept of *how* your messages are to be delivered. Instead of having your application code try to send an e-mail, have it put the message in a message queue in a database, and report back to the user that the message has been accepted for delivery. Then have a background process that is responsible for processing queued messaged. How and when you deal with messages that cannot be delivered in the end is something you must consider though, it's down to what you need the app to do basically.
There's also message queues like RabbitMQ, ZeroMQ and others that are more specialised for dealing with the actual communication between separate components in a system, but that's perhaps not something you need here.
It really comes down to what you need. Normally handing off a mail to an SMTP server shouldn't take more than a second or so, and that's surely an amount of time that your users are fine waiting? If it doesn't succeed maybe they're happier to get an error message right away than later on? Keeping it simple has some value too.
Not sure if that helped a lot, but in the end it's down to how failures should be handled on a business level I think. You build the system to accomodate that.
If it's just a matter of the SMTP server timing out for some reason, you could always give it one extra try (and log the error because it really shouldn't happen at all - if it does, there's something unhealthy with the infrastructure) before erroring out.
Regards, Leo
21 mar 2014 kl. 17.53 skrev jschwartz:
> Thanks for the suggestions.
>
> Leo: We actually ARE using a local mail server. But from time to time, you do get an error. I suspect it is due to a dictionary attache that might be going on at the time of the transactional email. The attack might be taking all the available ports.
>
> That being said, your suggestion for creating a separate service for delivering the transactional email is a good one. I’m just wondering if it is worth it for a 1:1000 occurrence. Do you actually use this method?
>
> Jonathan
>
>
> On Mar 20, 2014, at 2:33 PM, Leo R. Lundgren <leo at finalresort.org> wrote:
>
>> Just put the messages in a queue in a database and instead of having them be sent off by the current script, let that script complete (telling the user that the mail is queued for sending), and then have another process (running in the background or scheduled) doing the sending of mails that are queued. Or use a local MTA, since queueing mails and sending them off is what it's made for.
>>
>> In the end it boils down to how you want to present the status of messages to your users though.
>>
>>
>> 20 mar 2014 kl. 22.29 skrev Michael Sloper:
>>
>>> We were frustrated with our own mail mail host and switched to using Mandrill for this which specializes in transactional email. They have some nice tools and it is free until you send over 12K emails a month. I know this isn't exactly what you were asking about but this was a noticeable improvement for us.
>>>
>>> Michael Sloper
>>> Pre1 Software
>>>
>>> On Mar 20, 2014, at 12:15 PM, jschwartz <jschwartz at exit445.com> wrote:
>>>
>>>> Hi Folks,
>>>>
>>>> On an infrequent basis, a transactional email such as an order confirmation will fail to go through using PHPMailer when the smtp server doesn’t respond. Although it is infrequent, it does happened and the client freaks when it happens.
>>>>
>>>> Does anyone employ any means to retry failed sends either in a few milliseconds while the script is still running, or at some later time by tracking failed sends and running a re-send script using a cron script or the like?
>>>>
>>>> Thanks
>>>>
>>>> Jonathan
>>>>
>>>>
>>>>
>>>>
>>>> _______________________________________________
>>>> FX.php_List mailing list
>>>> FX.php_List at mail.iviking.org
>>>> http://www.iviking.org/mailman/listinfo/fx.php_list
>>>
>>> _______________________________________________
>>> FX.php_List mailing list
>>> FX.php_List at mail.iviking.org
>>> http://www.iviking.org/mailman/listinfo/fx.php_list
>>
>>
>>
>> -|
>>
>> _______________________________________________
>> FX.php_List mailing list
>> FX.php_List at mail.iviking.org
>> http://www.iviking.org/mailman/listinfo/fx.php_list
>
> _______________________________________________
> FX.php_List mailing list
> FX.php_List at mail.iviking.org
> http://www.iviking.org/mailman/listinfo/fx.php_list
-|
More information about the FX.php_List
mailing list