[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [bug-mailutils] multipart/alternative not displaying in Yahoo.com

From: Jean Louis
Subject: Re: [bug-mailutils] multipart/alternative not displaying in Yahoo.com
Date: Tue, 18 Apr 2017 21:59:16 +0300

On Tue, Apr 18, 2017 at 09:16:45PM +0300, Sergey Poznyakoff wrote:
> Jean Louis <address@hidden> ha escrit:
> > I am compiling and will let you know.
> Thanks.  I'm looking forward to it.
> > The email sending should be by standard, whatever Yahoo does, so I
> > hope that with my request, you did not disturb the standards of
> > sending such multipart emails.
> That's no problem, standards often leave sufficient leeway for 
> misunderstanding between client and server.  The case we're handling is
> just an example of this.  Interoperability is very important, and I
> appreciate very much your help ( and perseverance :) ) in resolving
> this problem.

Thank you. It is working now in Yahoo, I can see the message. It looks
like charset is being set automatically? The HTML file shows
iso-8859-1 and I just hope it does not disturb vieweing the HTML file
which has inside UTF-8 settings, I still think it can disturb it.

It can be that I caused this problem by adding the Content-Disposition
or by not using correctly the mail utility. Below you can find how I
am using it. 

;;; GNU Mailutils functions

;;; echo "Hello" | mail -a "Date: `/bin/date +'%a, %d %b %Y %T %z'`" -a "From: 
Mr. John Doe  <address@hidden>" -E 'set 
record=maildir:~/Maildir/address@hidden' -s "Test (DELETE ME)" address@hidden

(defun mu-set-record (maildir)
  (if maildir
    (format nil " -E 'set record=maildir:~~/Maildir/~a' " maildir)

(defun mu-subject (subject)
  (format nil " -s '~a' " subject))

(defun mu-from (name from)
  (format nil " -a \"From: ~a <~a>\" " name from))

(defun mu-header-unicode ()
  (concatenate 'string
               " -a \"Content-Type: text/plain; charset=utf-8\" "
               " -a \"Content-Disposition: inline\" "
               " -a \"Content-Transfer-Encoding: 8bit\" "))

(defun mu-html-alternative (file)
  (if (not (zerop (length file)))
    (format nil " --alternative --content-type=text/html --attach=~a" file)

(defun mu-to (name to)
  (setf name (substitute #\- #\@ name))
  (setf name (substitute #\. #\, name))
  (setf name (substitute #\Space #\. name))
  (if (> (length name) 0)
    (format nil " \"~a <~a>\" " name to)
    (format nil " \"~a\" " to)))

(defun mu-date ()
  (format nil " -a \"Date: `/bin/date +'%a, %d %b %Y %T %z'`\" "))

(defun mu-attach (file)
  (if (zerop (length (namestring file)))
    (format nil " -A \"~a\" " file)))

(defun mu-attachments (attachments)
  (if (listp attachments)
    (format nil " ~{~a~} " (map 'list #'mu-attach attachments))
    (mu-attach attachments)))

(defun mu-body-type (type)
  (format nil " --content-type=~a " type))

(defun mu-mail (&key from-name from-email to-email (to-name "") subject 
(set-record to-email) body (attachments "") (html-alternative "") (test nil)
                     (body-type "text/plain"))
  (let ((mu-mail (concatenate 'string
                              "mail -E \"unset askcc\" "
                              (mu-from from-name from-email)
                              (mu-set-record set-record)
                              (mu-subject subject)
                              (mu-html-alternative html-alternative)
                              (mu-attachments attachments)
                              (mu-to to-name to-email)
                              (mu-body-type body-type)
    (if test
      (format t "~%FROM: ~a ~a, TO: ~a ~a, SUBJECT: ~a~%"
              from-name from-email to-name to-email subject)
      (values (with-input-from-string (s body)
                (uiop:run-program mu-mail :input s :external-format 

;; (princ (cadr (multiple-value-list
;; (mu-mail :from-name "Jean Louis"
;;       :from-email "address@hidden"
;;       :to-email "address@hidden"
;;       :to-name "Jean Louis"
;;       :subject "Hello there"
;;          :body-type "text/plain"
;;       :body "Text message here čekaj ™ ® "
;;          :html-alternative "/home/data1/protected/public_html/index.html") ) 

;; :attachments (list "/tmp/file" "/tmp/anotherfile")

and this one I use to send email by using makemime utility:

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

(defun makemime-send (text html &key from-name from-email to-name to-email 
  (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/sendmail -F \"~a\" -f ~a" from-name 
 (string-to-command sendmail makemime)))

;; (send-example)

(defun send-example ()
 "Hello čč"
 "<!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 "Jean"
 :from-email "address@hidden"
 :to-name "Mr. L č™''"
 :to-email "address@hidden"
 :subject "Hello there čč ™ omasdans kjnaksnd kjansdjkn akjnd jknajksnd 

;; (send-example)

reply via email to

[Prev in Thread] Current Thread [Next in Thread]