diff options
Diffstat (limited to 'lisp/mail/smtpmail.el')
-rw-r--r-- | lisp/mail/smtpmail.el | 39 |
1 files changed, 26 insertions, 13 deletions
diff --git a/lisp/mail/smtpmail.el b/lisp/mail/smtpmail.el index ab58aa455e9..c1e22800331 100644 --- a/lisp/mail/smtpmail.el +++ b/lisp/mail/smtpmail.el @@ -207,11 +207,15 @@ for `smtpmail-try-auth-method'.") ;; Examine this variable now, so that ;; local binding in the mail buffer will take effect. (smtpmail-mail-address - (or (and mail-specify-envelope-from (mail-envelope-from)) - (let ((from (mail-fetch-field "from"))) - (and from - (cadr (mail-extract-address-components from)))) - (smtpmail-user-mail-address))) + (save-restriction + ;; Only look at the headers when fetching the + ;; envelope address. + (message-narrow-to-headers) + (or (and mail-specify-envelope-from (mail-envelope-from)) + (let ((from (mail-fetch-field "from"))) + (and from + (cadr (mail-extract-address-components from)))) + (smtpmail-user-mail-address)))) (smtpmail-code-conv-from (if enable-multibyte-characters (let ((sendmail-coding-system smtpmail-code-conv-from)) @@ -434,7 +438,12 @@ for `smtpmail-try-auth-method'.") (let ((coding-system-for-read 'no-conversion)) (insert-file-contents file-data)) (let ((smtpmail-mail-address - (or (and mail-specify-envelope-from (mail-envelope-from)) + (or (and mail-specify-envelope-from + (save-restriction + ;; Only look at the headers when fetching the + ;; envelope address. + (message-narrow-to-headers) + (mail-envelope-from))) user-mail-address))) (if (not (null smtpmail-recipient-address-list)) (when (setq result (smtpmail-via-smtp @@ -677,13 +686,17 @@ Returns an error if the server cannot be contacted." ;; `smtpmail-mail-address' should be set to the appropriate ;; buffer-local value by the caller, but in case not: (envelope-from - (or smtpmail-mail-address - (and mail-specify-envelope-from - (mail-envelope-from)) - (let ((from (mail-fetch-field "from"))) - (and from - (cadr (mail-extract-address-components from)))) - (smtpmail-user-mail-address))) + (save-restriction + ;; Only look at the headers when fetching the + ;; envelope address. + (message-narrow-to-headers) + (or smtpmail-mail-address + (and mail-specify-envelope-from + (mail-envelope-from)) + (let ((from (mail-fetch-field "from"))) + (and from + (cadr (mail-extract-address-components from)))) + (smtpmail-user-mail-address)))) process-buffer result auth-mechanisms |