diff options
| author | Kenichi Handa | 2011-05-23 13:44:29 +0900 |
|---|---|---|
| committer | Kenichi Handa | 2011-05-23 13:44:29 +0900 |
| commit | b8d747b9bd6e8278349aa7faaf4bbbf0b9ce24db (patch) | |
| tree | ea4cdbf9c5cc9a10cfdb90d3fd6c49fdcda10c62 | |
| parent | 02bd54507635629c9d35bc2193a0cfa3567309c6 (diff) | |
| download | emacs-b8d747b9bd6e8278349aa7faaf4bbbf0b9ce24db.tar.gz emacs-b8d747b9bd6e8278349aa7faaf4bbbf0b9ce24db.zip | |
RFC2047-encode header of outgoing mails.
| -rw-r--r-- | lisp/ChangeLog | 11 | ||||
| -rw-r--r-- | lisp/mail/sendmail.el | 25 | ||||
| -rw-r--r-- | lisp/mail/smtpmail.el | 2 |
3 files changed, 35 insertions, 3 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog index 9d591146cbe..bad99e7294b 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog | |||
| @@ -1,3 +1,14 @@ | |||
| 1 | 2011-05-23 Kenichi Handa <handa@m17n.org> | ||
| 2 | |||
| 3 | * mail/sendmail.el: Require `rfc2047'. | ||
| 4 | (mail-insert-from-field): Do not perform RFC2047 encoding. | ||
| 5 | (mail-encode-header): New function. | ||
| 6 | (sendmail-send-it): Set buffer-file-coding-system of the work | ||
| 7 | buffer to the return value of select-message-coding-system. Call | ||
| 8 | mail-encode-header. | ||
| 9 | |||
| 10 | * mail/smtpmail.el (smtpmail-send-it): Call mail-encode-header. | ||
| 11 | |||
| 1 | 2011-05-22 Sean Neakums <sneakums@zork.net> (tiny change) | 12 | 2011-05-22 Sean Neakums <sneakums@zork.net> (tiny change) |
| 2 | 13 | ||
| 3 | * mail/supercite.el (sc-default-cite-frame): Handle | 14 | * mail/supercite.el (sc-default-cite-frame): Handle |
diff --git a/lisp/mail/sendmail.el b/lisp/mail/sendmail.el index 8cd650317b1..b6fd586c2ed 100644 --- a/lisp/mail/sendmail.el +++ b/lisp/mail/sendmail.el | |||
| @@ -34,7 +34,7 @@ | |||
| 34 | (require 'rmail) | 34 | (require 'rmail) |
| 35 | (require 'mailalias)) | 35 | (require 'mailalias)) |
| 36 | 36 | ||
| 37 | (autoload 'rfc2047-encode-string "rfc2047") | 37 | (require 'rfc2047) |
| 38 | 38 | ||
| 39 | (defgroup sendmail nil | 39 | (defgroup sendmail nil |
| 40 | "Mail sending commands for Emacs." | 40 | "Mail sending commands for Emacs." |
| @@ -952,12 +952,14 @@ of outgoing mails regardless of the current language environment. | |||
| 952 | See also the function `select-message-coding-system'.") | 952 | See also the function `select-message-coding-system'.") |
| 953 | 953 | ||
| 954 | (defun mail-insert-from-field () | 954 | (defun mail-insert-from-field () |
| 955 | "Insert the \"From:\" field of a mail header. | ||
| 956 | The style of the field is determined by the variable `mail-from-style'. | ||
| 957 | This function does not perform RFC2047 encoding." | ||
| 955 | (let* ((login user-mail-address) | 958 | (let* ((login user-mail-address) |
| 956 | (fullname (user-full-name)) | 959 | (fullname (user-full-name)) |
| 957 | (quote-fullname nil)) | 960 | (quote-fullname nil)) |
| 958 | (if (string-match "[^\0-\177]" fullname) | 961 | (if (string-match "[^\0-\177]" fullname) |
| 959 | (setq fullname (rfc2047-encode-string fullname) | 962 | (setq quote-fullname t)) |
| 960 | quote-fullname t)) | ||
| 961 | (cond ((null mail-from-style) | 963 | (cond ((null mail-from-style) |
| 962 | (insert "From: " login "\n")) | 964 | (insert "From: " login "\n")) |
| 963 | ;; This is deprecated. | 965 | ;; This is deprecated. |
| @@ -1017,6 +1019,20 @@ See also the function `select-message-coding-system'.") | |||
| 1017 | (goto-char fullname-start)))) | 1019 | (goto-char fullname-start)))) |
| 1018 | (insert ")\n"))))) | 1020 | (insert ")\n"))))) |
| 1019 | 1021 | ||
| 1022 | (defun mail-encode-header (beg end) | ||
| 1023 | "Encode the mail header between BEG and END according to RFC2047. | ||
| 1024 | Return non-nil if and only if some part of the header is encoded." | ||
| 1025 | (save-restriction | ||
| 1026 | (narrow-to-region beg end) | ||
| 1027 | (let* ((selected (select-message-coding-system)) | ||
| 1028 | (mm-coding-system-priorities | ||
| 1029 | (if (and selected (coding-system-get selected :mime-charset)) | ||
| 1030 | (cons selected mm-coding-system-priorities) | ||
| 1031 | mm-coding-system-priorities)) | ||
| 1032 | (tick (buffer-chars-modified-tick))) | ||
| 1033 | (rfc2047-encode-message-header) | ||
| 1034 | (= tick (buffer-chars-modified-tick))))) | ||
| 1035 | |||
| 1020 | ;; Normally you will not need to modify these options unless you are | 1036 | ;; Normally you will not need to modify these options unless you are |
| 1021 | ;; using some non-genuine substitute for sendmail which does not | 1037 | ;; using some non-genuine substitute for sendmail which does not |
| 1022 | ;; implement each and every option that the original supports. | 1038 | ;; implement each and every option that the original supports. |
| @@ -1060,6 +1076,7 @@ external program defined by `sendmail-program'." | |||
| 1060 | (unless multibyte | 1076 | (unless multibyte |
| 1061 | (set-buffer-multibyte nil)) | 1077 | (set-buffer-multibyte nil)) |
| 1062 | (insert-buffer-substring mailbuf) | 1078 | (insert-buffer-substring mailbuf) |
| 1079 | (set-buffer-file-coding-system selected-coding) | ||
| 1063 | (goto-char (point-max)) | 1080 | (goto-char (point-max)) |
| 1064 | ;; require one newline at the end. | 1081 | ;; require one newline at the end. |
| 1065 | (or (= (preceding-char) ?\n) | 1082 | (or (= (preceding-char) ?\n) |
| @@ -1166,6 +1183,8 @@ external program defined by `sendmail-program'." | |||
| 1166 | (if mail-interactive | 1183 | (if mail-interactive |
| 1167 | (with-current-buffer errbuf | 1184 | (with-current-buffer errbuf |
| 1168 | (erase-buffer)))) | 1185 | (erase-buffer)))) |
| 1186 | ;; Encode the header according to RFC2047. | ||
| 1187 | (mail-encode-header (point-min) delimline) | ||
| 1169 | (goto-char (point-min)) | 1188 | (goto-char (point-min)) |
| 1170 | (if (let ((case-fold-search t)) | 1189 | (if (let ((case-fold-search t)) |
| 1171 | (or resend-to-addresses | 1190 | (or resend-to-addresses |
diff --git a/lisp/mail/smtpmail.el b/lisp/mail/smtpmail.el index f59e8b02cd0..a68e1e6b1f2 100644 --- a/lisp/mail/smtpmail.el +++ b/lisp/mail/smtpmail.el | |||
| @@ -362,6 +362,8 @@ The list is in preference order.") | |||
| 362 | (if mail-interactive | 362 | (if mail-interactive |
| 363 | (with-current-buffer errbuf | 363 | (with-current-buffer errbuf |
| 364 | (erase-buffer)))) | 364 | (erase-buffer)))) |
| 365 | ;; Encode the header according to RFC2047. | ||
| 366 | (mail-encode-header (point-min) delimline) | ||
| 365 | ;; | 367 | ;; |
| 366 | (setq smtpmail-address-buffer (generate-new-buffer "*smtp-mail*")) | 368 | (setq smtpmail-address-buffer (generate-new-buffer "*smtp-mail*")) |
| 367 | (setq smtpmail-recipient-address-list | 369 | (setq smtpmail-recipient-address-list |