Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Handling undelivered emails in webapp

Tags:

email

We have a typical business web app that allows our users to send e-mails with offerings to their clients. We set user e-mail in FROM field so the client can reply directly to the user. The problem is that because of SMTP protocol, undelivered e-mail notification is returned to our e-mail address(the address of the account we send e-mails from).

Do you know elegant way to handle this undelivered emails? I mean the easiest way to let the sender know that his mail was not delivered.

like image 589
jakub.piasecki Avatar asked Sep 23 '08 22:09

jakub.piasecki


People also ask

How do I fix undelivered emails?

Try these fixes: Make sure the recipient address is valid. Reduce the number of recipients in the message. If you received this error when sending a message using Outlook or another email app, try using Outlook.com to send the message instead.

Where do undelivered emails go?

By default, any undelivered message is returned to the sender with an NDR and deleted from the queue.

What causes emails to be undeliverable?

If bounced emails are in the “Undeliverable” category, that means that the receiving email server is temporarily unavailable, was overloaded, or couldn't be found. A server that can't be found could have crashed or been under maintenance, so this may just mean waiting to send the email to the address again.


1 Answers

First, it's important to understand the difference between the "From:" header (which the recipient sees in their email client) and the sender address (which is also called the envelope return path, or the argument to the SMTP "MAIL FROM" command). The sender address is where bounce messages go when the email can't be delivered, hence the other name return path.

SMTP doesn't restrict what address you use as the sender address (except that it must by syntactically valid), but whatever SMTP client library you use might, so you'll need to check that out.

Changing the sender address is where you can do clever things to help detect email bounces and report them back to the webapp or sender. The most common thing you'll see is to encode the recipient address in the sender address, e.g. with a sender address like this: [email protected]. The MTA responsible for senderdomain.com needs to know to deliver all emails for [email protected] to [email protected] -- but that's a fairly common requirement. Then you take the email that is received, and instead of trying to work out from the bounce message in the contents (which could be in any format) who the recipient was, you can get it right from the recipient address.

You can do more complex things as well, like hashing the recipient address so it's not visible directly in the sender address, e.g. [email protected]. And you could include some identifier for the email that was sent, in case you're sending multiple emails to the same address and want to know which one bounced.

These tricks are called Variable Envelope Return Path or VERP, and are commonly implemented by mailing list software.

like image 116
TimB Avatar answered Oct 11 '22 19:10

TimB