I'm using the smtp-mail library to send emails from my application with the sendMailWithLogin' function.
I would like to know if the email was successfully delivered or if it bounced. And if it bounced, with what error code? All of the functions return IO ()
and digging through the code it's a lot of layers of IO ()
. Is there some way to get this information with this library? Or is there perhaps some other library that can be used?
I'm using the smtp-mail library to send emails from my application with the sendMailWithLogin' function.
I would like to know if the email was successfully delivered or if it bounced. And if it bounced, with what error code? All of the functions return IO ()
and digging through the code it's a lot of layers of IO ()
. Is there some way to get this information with this library? Or is there perhaps some other library that can be used?
1 Answer
Reset to default 3Unfortunately your software will have to become significantly more complex to support this. If you want to discover a bounce notification, you will at minimum need to be able to receive mail, which is not the purview of SMTP; you will need to make a POP or IMAP client. Also keep in mind that
- I'm pretty sure there's no obligation for an SMTP server to notify you of a bounce.
- A failed sending is retried, often for several days, before giving up.
- There is, as far as I know, no standard mechanism for bounce notification, so you will be solving a somewhat difficult problem. Getting coverage of all the formats used by all the world's email servers likely has a very long tail; perhaps a more modern version of this would be using some AI (e.g. an LLM) or statistical model (e.g. one of the standardish spam filtering techniques, but retooled for detecting bounces instead of spam) to try to actually understand the text inside emails you get back.
IO ()
" really? – cafce25 Commented 4 hours ago