The docs on cl-smtp are a little, um, terse, so I figured I’d post a few snippets for google to find:
Sending html email with cl-smtp:
(cl-smtp:send-email
+mail-server+
"from-email@example.com"
"to-email@example.com"
"Subject"
"<html><body>
<p>
Shiny <strong>h</strong><em>t</em><small>m</small>l.
</p>
<p>
</body></html>"
:extra-headers '(("Content-type" "text/html; charset=\"iso-8859-1\"")))
Sending attachments with cl-smtp:
(cl-smtp:send-email
+mail-server+
"from-email@example.com"
"to-email@example.com"
"Subject"
"see attachement"
:attachments '("/path/to/attachment"))
Ok, back to my regularly scheduled slog.
Boomer | 31-Oct-08 at 12:47 pm | Permalink
Thanks! I’ve been googling for something like this. Your timing is perfect.
Leslie P. Polzer | 01-Nov-08 at 4:44 am | Permalink
Hans’ BKNR branch of CL-SMTP has some additional MIME attachment features:
http://bknr.net/trac/browser/trunk/thirdparty/cl-smtp/
And here’s an utility library for sending UTF-8 mail:
http://groups.google.com/group/cl-terrace/web/trivial-email-utf-8
Cheers,
Leslie
Alejandro Atienza Ramos | 02-Nov-08 at 6:19 pm | Permalink
It would be perfect to complement it with how to download mail from the same email account, although, obviously, not with smtp…
Victor | 03-Nov-08 at 9:32 am | Permalink
This tip could be contributed to the “Common Lisp” Wikibook, section “Libraries”.
JC | 05-Nov-08 at 6:54 pm | Permalink
AFAIK, all cl-smtp(old, new, forked, etc) implementation do not handle encoding subject and content correctly(or hard to use). In my mind, the correct implementation should use Flexi stream to deal with different encodings for the content at least
Russ’s Tech Blog » Blog Archive » Sending HTML Email with attachments in Common Lisp | 23-Mar-09 at 11:17 am | Permalink
[...] 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. [...]
Jeff Cunningham | 28-Feb-13 at 6:48 pm | Permalink
Hi – Google found your snippets on cl-smtp (thanks!). I’m trying to figure out why attachments don’t work and wondering if a bug has crept into the code since you posted this. Would you mind trying your example and letting me know if it still works for you? Mine generate this error:
#
[Condition of type SMTP-PROTOCOL-ERROR]
Regards,
Jeff C.