gen-smtp / gen_smtp

The extensible Erlang SMTP client and server library.
Other
683 stars 266 forks source link

Add LMTP as an option for the protocol implementation #255

Closed abravalheri closed 3 years ago

abravalheri commented 3 years ago

Hello,

I would like to thank the maintainers for the amazing work and propose this PR as my attempt to add support for LMTP. This feature was requested in #196, and is something I find very appropriate, mainly because of the following reasons:

  1. LMTP is a very similar protocol to SMTP. In practice it looks more of a variation of SMTP than a completely different protocol... Therefore it makes sense to implement both of them together and avoid code duplication between two different projects and code base.
  2. Instead of dealing with the complexity of implementing robust and secure SMTP servers by themselves, a considerable part of developers prefer to deploy other battle-tested solution (with advanced features like anti-spam/anti-virus/grey listing integration like Postfix, OpenSMTPD and Exim) and only then place a custom LMTP server behind it.

The implementation I attempted follow more or less the guidelines stablished in #196 and any suggestions for improvement are welcome (in fact this is my very first time writing something in Erlang, so still learning...).

I have also implemented a proof of concept/integration test using OpenSMTPD and docker in https://github.com/abravalheri/lmtp_poc, and things seem to work fine.

Unfortunately I was not able to think in an easy solution for optimising the separation of concerns without requiring duplication of code, but if the maintainers have any ideas and would like to guide me in the process, I am open to go through more iterations of this PR.

abravalheri commented 3 years ago

Thank you very much for the review @seriyps.

This is also the first time I am working with LMTP, so I am not that experienced either. What I did was to follow RFC2033 and the recommendations of @Elemecca / @Shemeikka on #196. Maybe they have a bit more experience and could also have a look?

To increase my confidence with the code, I did implement a quick experiment using OpenSMTPD to deliver local emails via LMTP to gen_smtp.

seriyps commented 3 years ago

Merged! Thanks @abravalheri @mworrell