makemime.lisp - creates the multipart/alternative MIME message by using Courier MTA's makemime tool and sends it by using sendmail


makemime.lisp is small peace of software that creates the multipart/alternative message by using the Courier MTA's excellent command line tool makemime and sendmail.

This piece of software in RCD Business replaces the need for cl-sendmail or cl-smtp yet it is effective and fast.

This Lisp function, with some adaptations may be used to effectively send the multipart/alternative MIME messages directly from a command line.

We will gladly adapt the software for your needs that you become able to send multipart/alternative MIME messages directly from command line.

The function is very simple and it may be implemented in any other programming language.

;; (ql)
;; (ql:quickload "alexandria")
;; (ql:quickload "cl-rfc2047")

(defun makemime-send (text html &key from-name from-email to-name to-email subject)
  "Creates multipart/alternative MIME message and sends it by using sendmail"
  (let* ((text-file "/dev/shm/text-file")
         (html-file "/dev/shm/html-file")
         (text-file (progn
                      (alexandria:write-string-into-file text text-file :if-does-not-exist :create :if-exists :supersede)
         (html-file (progn
                      (alexandria:write-string-into-file html html-file :if-does-not-exist :create :if-exists :supersede)
         (makemime-file "/dev/shm/makemime")
         (makemime-set (alexandria:write-string-into-file (format nil "-j
Mime-Version: 1.0
From: ~a <~a>
To: ~a <~a>
Subject: ~a
Content-Disposition: inline
-C utf-8
-c text/plain
-C utf-8
-c text/html
-C utf-8
" (cl-rfc2047:encode from-name) from-email
  (cl-rfc2047:encode to-name) to-email
  subject text-file html-file) makemime-file :if-exists :supersede :if-does-not-exist :create))
    (makemime (slurp-stream-io-command "makemime @-" makemime-set))
    (sendmail (format nil "/usr/bin/env TO-NAME=\"~a\" TO-EMAIL=\"~a\" /usr/bin/sendmail -F \"~a\" -f ~a" to-name to-email from-name from-email)))
    (multiple-value-bind (output error status)
        (string-to-command sendmail makemime)
      (declare (ignore output error))

;; (send-example)

(defun send-example ()
  (let ((status 
 "Hello ® UTF-8 ŠđŽ"
 "<!doctype html public \"-//W3C//DTD HTML 4.0 Transitional //EN\">
  <meta http-equiv=\"Content-Type\"
        content=\"text/html; charset=utf-8\">  <title></title>
<h2>Hello there</h2>


<p>This is some text here. č</p>
 :from-name "Mr. From"
 :from-email ""
 :to-name "Mr. Who"
 :to-email ""
 :subject " #$%&/(`°=˝?'*+÷פß") ))

Leave Your Comment or Contact GNU.Support

Contact GNU.Support now. There is a simple rule at GNU.Support: if we can help you, we do, whenever and wherever necessary, and it's the way we've been doing business since 2002, and the only way we know

Full name: