Sending HTML Email with attachments in Common Lisp

Ryepup gave us a great couple of simple examples for CL-SMTP.  Unfortunately when I tried to combine them to send an HTML email that had an attachment, I did not get the expected results.  Instead, we insert an inappropriate ContentType header above the multipart then the message body has content type text/plain.  I saw Leslie Polzer’s comment about a BKNR branch of cl-smtp that handled mime-types better.  So I downloaded it, fired it up, bound the content-type variable and it almost produced the correct email.  Unfortunately the result email was missing a newline after the header so my client skipped displaying this first email part (assuming it to be part of the header).  I submitted a patch, that was accepted, that adds the newline after the multipart message header.

[Paste Example]

2 thoughts on “Sending HTML Email with attachments in Common Lisp

  1. Can you please provide me with a working sample of this?
    I can’t get HTML + attachment to work and since I am new to LISP I don’t understand your “fix”

    Thank you

  2. Well, I mostly downloaded a different branch of the library that had a *content-type* variable, then I bound the variable to the *content-type* I was trying to send.

    Here is an example call:

    Sorry it took so long to see this, your comment got spammed and I didnt get notified

Leave a Reply

Your email address will not be published.