Sending an email via SMTP

I know of 2 that look more or less decent:

What library would you recommend?
It should be more or less mature, and not abandoned.

There is mrmime for building the email and colombe for the SMTP protocol.
Letters is a simple (easier to use but limited) wrapper over these libraries.

Here is an example of use of mrmime: https://github.com/Julow/rss_to_mail/blob/master/main_native/mail.ml#L33-L106
and colombe: https://github.com/Julow/rss_to_mail/blob/master/main_native/mail.ml#L110-L132

Other examples I know are unfortunately outdated.

1 Like

Like @Juloo said, colombe and mrmime are there for sending emails over SMTP. While very powerful and somewhat low level, they are not too easy to use. That’s why I created letters that aims to be super easy to use library, while somewhat limited in features. It is still build on mrmime and colombe so you can also use it as an example.

I’m in the process of adding mimetype/alternative support in few days and there’s also PR in works for easier discovery for CA certificates.

After that I think we’ll tackle attachments and better message abstraction (sihl needs support for serialising messages for job queues).

If you prefer generating your emails manually, you can still generate them using mrmime and use letters to simplify sending them. Later I’ll add also support to use any other string stream to provide the email itself, if you don’t want to use mrmime.

Feel free to drop any improvement ideas or feature requests and we’ll see when those can be implemented. Currently the development has been a bit slow as I’ve been otherwise busy, but hopefully we can speed up things soon.

2 Likes