Net/smtp sending with attachments

I'm trying to use net/smtp to send emails that contain calendar invites. I can't seem to find a library that with let me construct the body of an email using MIME. I can probably create what I need using https://github.com/mflatt/sirmail/blob/master/sirmail/sendr.rkt#L136 as a model.

But before I go down that path I wanted to ask for a sanity check to make sure I'm not overlooking an existing module or something else I should look at to handle the construction of MIME formatted emails. Any suggestions?

3 Likes

I don't know of any existing library for MIME writing. In response to an old mailing-list question from Christine Lemmer Webber, I posted some code I've written at GitHub - LiberalArtist/multipart-writing-examples: Examples of multipart writing in Racket. (This was before Racket's license change: I'm happy to relicense it (Apache-2.0 OR MIT). I'll update the repository eventually.) Do see the mailing list for some important caveats about the code and considerations for someone undertaking a general-purpose library!

The email code I posted is specific to multipart/alternative (e.g. sending text/html email with text/plain fallback): I think I've written versions of it that handle attachments, too, but if so I don't know where I've put them.

The code I posted also uses net/sendmail, but I've adapted it for use with net/smtp, and I do know where I've put that. I'll post it too once I've ripped out the specific email hard-coded into the script I wrote most recently.

If I were going to use the long random boundary strategy described (IIRC) in the RFC, I'd probably use my uuid: Universally Unique Identifiers library.

1 Like