gen-smtp / gen_smtp

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

Add LMTP support to the gen_smtp_client #321

Closed pablowillians closed 2 years ago

pablowillians commented 2 years ago

Hey team!

First of all, I would like to thank you guys for this exceptional work! Second, I am proposing supporting LMTP in delivering messages.

It would be really useful in cases when it's needed to deliver messages to an LMTP server (ie, Dovecot)

Usage example:

Socket = gen_smtp_client:open([{relay, "local-dovecot"}, {protocol, lmtp}])
gen_smtp_client:deliver(Socket, {"whatever@test.com", ["pablo@example.com"],
 "Subject: testing\r\nFrom: Andrew Thompson <andrew@hijacked.us>\r\nTo: Some Dude <foo@bar.com>\r\n\r\nThis is the email body"}).

I would love to receive suggestions to improve it. This is my first time writing Erlang code.

Thank you

pablowillians commented 2 years ago

@mworrell The workflow found an issue with formatting, so I updated the PR. Could you please approve the workflows to run again?

pablowillians commented 2 years ago

Thanks, @mworrell ! I've made changes to the rebar.config's file as well, since it was throwing a badmap error when trying to generate docs

mworrell commented 2 years ago

So the basic difference is that we have to say LHLO? And all else is the same?

pablowillians commented 2 years ago

So the basic difference is that we have to say LHLO? And all else is the same?

Actually, it has one more difference:

The change is that after the final ".", the server returns one reply for each previously successful RCPT command in the mail transaction

So I added some tests similar to the example from the LMTP documentation, to reflect that behavior.

mworrell commented 2 years ago

Looks good! I like how you also added tests and updated the docs.

Thank you!