Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add LMTP as an option for the protocol implementation #255

Merged
merged 12 commits into from
Apr 20, 2021

Conversation

abravalheri
Copy link
Contributor

@abravalheri abravalheri commented Mar 22, 2021

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.

gen_smtp_server_session already aggregate all the recipients in a
non empty list of strings, no extra checks are required.
This change in naming is compatible with the common jargon, and is also
used in other softwares.
For example, the mstmp client defines  a `--protocol=smtp|lmtp` option
(https://manpages.debian.org/testing/msmtp-mta/sendmail.8.en.html)
Copy link
Collaborator

@seriyps seriyps left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! I think it looks quite good, but I have no experience with LMTP. Would really appreciate if you implement the changes I asked for.

src/gen_smtp_server_session.erl Outdated Show resolved Hide resolved
src/gen_smtp_server_session.erl Outdated Show resolved Hide resolved
src/gen_smtp_server_session.erl Outdated Show resolved Hide resolved
src/smtp_server_example.erl Outdated Show resolved Hide resolved
- Combine similar clauses of `gen_smtp_server_session:randle_request`
  for HELLO, EHLO and LHLO.
- Move `report_recipient` and `queue_or_delivery` to the ends of their
  documents, so functions are defined "from top to down".
Copy link
Collaborator

@seriyps seriyps left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great work! Thanks! Let's see what @mworrell and @arjan think.

@abravalheri
Copy link
Contributor Author

abravalheri commented Mar 24, 2021

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.

@abravalheri abravalheri mentioned this pull request Mar 24, 2021
Copy link
Collaborator

@seriyps seriyps left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we merge it @mworrell @arjan ?

@seriyps seriyps requested a review from mworrell April 16, 2021 19:31
@seriyps seriyps merged commit 3f916de into gen-smtp:master Apr 20, 2021
@seriyps
Copy link
Collaborator

seriyps commented Apr 20, 2021

Merged! Thanks @abravalheri @mworrell

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants