gen_smtp: be notified on failed delivery message

Leonard B leonard.boyce@REDACTED
Wed Jan 13 20:59:42 CET 2021


Hi Frank,

There are basically 2 classes of errors.

1. Errors which are derived from the delivery process. These would include
  a) network errors (nxdomain etc)
  b) mailboxes not existing/disabled etc (response to RCPT TO command.
Be aware that many servers do *not* follow the RFC and will lie)
  c) the dreaded 'blocking' of you connection for whatever reason the
remote server decides to use

2. 'soft bounce' errors:
  These occur when certain servers, eg outlook, will accept an email
for delivery, and then email you back to tell you about some type of
error.
  You'd need to have a server receiving mail to receive the 'soft'
errors since they are email back to you and not part of the SMTP
transaction.

There is a 3rd class of error (Yahoo/AOL and friends):
Their servers will say that the mailbox exists (in response to RCPT
TO:) and then tell you a mailbox does not exist _after you send your
DATA_.

Kind regards,
Leonard

On Wed, Jan 13, 2021 at 1:31 PM Frank Muller <frank.muller.erl@REDACTED> wrote:
>
> Thanks for the pointers Marc.
>
> Do I need to implement the server part to check for errors? Can’t the gen_smtp “client” be notified in case of misspelled address (or unresolved domain, MX, etc.)?
>
> /Frank
>
> Wed. 13 jan 2021 10:25, Marc Worrell <marc@REDACTED> wrote :
>>
>> Hi Frank,
>>
>> Yes, gen_smtp can report failures that happen during communication with the remote smtp server.
>> Will also report failures if it can’t resolve the domain or find a MX server.
>>
>> Late bounces (sent by the remote mail agent) must be handled by your own code.
>>
>> In Zotonic we have an example of handling such bounces.
>>
>> Check for our mail sending code (which also uses mnesia for queueing):
>>
>> https://github.com/zotonic/zotonic/blob/master/apps/zotonic_core/src/smtp/z_email_server.erl
>>
>> And for receiving email, including parsing and handling of bounce messages:
>>
>> https://github.com/zotonic/zotonic/tree/master/apps/zotonic_listen_smtp/src
>>
>> Cheers,
>>
>> Marc
>>
>>
>> On 13 Jan 2021, at 09:18, Frank Muller <frank.muller.erl@REDACTED> wrote:
>>
>> Hi everyone
>>
>> I’m considering using gen_smtp (https://github.com/gen-smtp/gen_smtp) in one of my apps.
>>
>> Question: is there a way to be notified on failed delivery message if for example the destination email address was misspelled?
>>
>> Thanks
>> /Frank
>>
>>


More information about the erlang-questions mailing list