Question

Similarly to a rest api, I want a server to listen for an email to an address I have created, and in response to mail being received, run code that I have created. Is this possible already? I understand how to call an api or create a micro service, but it seems like triggering code when someone sends an email is esoteric.

In my research, it seems like I need an smtp server and pubsub data structure. However, in the implementations I have found on GitHub, it seems they are more tailored to sending email rather than triggering code when a user receives an email. I would prefer not to use sengrid or ses aws.

If smtp server is what I need, do you think it is something I can complete in a semester.

Was it helpful?

Solution

Common e-mail server software (postfix, sendmail, presumably exim but I didn't check that one) supports forwarding to programs via pipes, so this isn't esoteric at all.

Ticketing systems such as Redmine and mailing list managers such as GNU Mailman use it all the time.

If you prefer not to run your own e-mail server, you can programmatically access mailboxes at almost any provider using POP3 or IMAP protocols. This will cause some delays due to polling, but e-mail isn't supposed to be real-time anyway.

Licensed under: CC-BY-SA with attribution
scroll top