]> git.eshelyaron.com Git - emacs.git/commitdiff
(smtpmail-send-it): Copy buffer-file-coding-system from the mail buffer.
authorEli Zaretskii <eliz@gnu.org>
Fri, 24 Nov 2006 14:33:19 +0000 (14:33 +0000)
committerEli Zaretskii <eliz@gnu.org>
Fri, 24 Nov 2006 14:33:19 +0000 (14:33 +0000)
Possibly add a MIME header for the message encoding.  Bind
coding-system-for-write around the call to mail-do-fcc.  Use
smtpmail-code-conv-from to encode queued mail messages.

lisp/ChangeLog
lisp/mail/smtpmail.el

index 26115e5959c58ae71ebd6b200b6dfb79ed7a13dc..1cef367ff453583bbf79fb0a6827459951c7d3f7 100644 (file)
@@ -1,3 +1,11 @@
+2006-11-24  Eli Zaretskii  <eliz@gnu.org>
+
+       * mail/smtpmail.el (smtpmail-send-it): Copy
+       buffer-file-coding-system from the mail buffer.  Possibly add a
+       MIME header for the message encoding.  Bind
+       coding-system-for-write around the call to mail-do-fcc.  Use
+       smtpmail-code-conv-from to encode queued mail messages.
+
 2006-11-24  Juanma Barranquero  <lekktu@gmail.com>
 
        * net/rcirc.el (rcirc-buffer-maximum-lines):
index ac87a93b7a177feb02a94b750dad614cab7791b6..271c7a76ca2a021b4c35ec7f00778c6b694e68d8 100644 (file)
@@ -244,6 +244,11 @@ This is relative to `smtpmail-queue-dir'.")
        (save-excursion
          (set-buffer tembuf)
          (erase-buffer)
+         ;; Use the same buffer-file-coding-system as in the mail
+         ;; buffer, otherwise any write-region invocations (e.g., in
+         ;; mail-do-fcc below) will annoy with asking for a suitable
+         ;; encoding.
+         (set-buffer-file-coding-system smtpmail-code-conv-from nil t)
          (insert-buffer-substring mailbuf)
          (goto-char (point-max))
          ;; require one newline at the end.
@@ -326,6 +331,22 @@ This is relative to `smtpmail-queue-dir'.")
            (goto-char (point-min))
            (unless (re-search-forward "^Date:" delimline t)
              (insert "Date: " (message-make-date) "\n"))
+           ;; Possibly add a MIME header for the current coding system
+           (let (charset)
+             (goto-char (point-min))
+             (and (eq mail-send-nonascii 'mime)
+                  (not (re-search-forward "^MIME-version:" delimline t))
+                  (progn (skip-chars-forward "\0-\177")
+                         (/= (point) (point-max)))
+                  smtpmail-code-conv-from
+                  (setq charset
+                        (coding-system-get smtpmail-code-conv-from
+                                           'mime-charset))
+                  (goto-char delimline)
+                  (insert "MIME-version: 1.0\n"
+                          "Content-type: text/plain; charset="
+                          (symbol-name charset)
+                          "\nContent-Transfer-Encoding: 8bit\n")))
            ;; Insert an extra newline if we need it to work around
            ;; Sun's bug that swallows newlines.
            (goto-char (1+ delimline))
@@ -334,7 +355,10 @@ This is relative to `smtpmail-queue-dir'.")
            ;; Find and handle any FCC fields.
            (goto-char (point-min))
            (if (re-search-forward "^FCC:" delimline t)
-               (mail-do-fcc delimline))
+               ;; Force mail-do-fcc to use the encoding of the mail
+               ;; buffer to encode outgoing messages on FCC files.
+               (let ((coding-system-for-write smtpmail-code-conv-from))
+                 (mail-do-fcc delimline)))
            (if mail-interactive
                (with-current-buffer errbuf
                  (erase-buffer))))
@@ -370,6 +394,7 @@ This is relative to `smtpmail-queue-dir'.")
                (make-directory smtpmail-queue-dir t))
              (with-current-buffer buffer-data
                (erase-buffer)
+               (set-buffer-file-coding-system smtpmail-code-conv-from nil t)
                (insert-buffer-substring tembuf)
                (write-file file-data)
                (set-buffer buffer-elisp)