From 8ce192e317f321834851e31571833f33aa332aa2 Mon Sep 17 00:00:00 2001 From: Lars Ingebrigtsen Date: Tue, 4 Sep 2012 18:00:10 +0200 Subject: [PATCH] Have smtpmail.el prefer the From: header for the MAIL FROM envelope * mail/smtpmail.el (smtpmail-send-it): Prefer the From: header over `user-mail-address' for the SMTP MAIL FROM envelope. (smtpmail-via-smtp): Ditto. --- etc/NEWS | 4 ++++ lisp/ChangeLog | 6 ++++++ lisp/mail/smtpmail.el | 12 +++++------- 3 files changed, 15 insertions(+), 7 deletions(-) diff --git a/etc/NEWS b/etc/NEWS index a2d0ffe232c..16e078fa639 100644 --- a/etc/NEWS +++ b/etc/NEWS @@ -1403,6 +1403,10 @@ If you had that set, you need to put in your ~/.authinfo file instead. +*** SMTPmail defaults to using the address in the From: header as the +SMTP MAIL FROM envelope. To override this, set `mail-envelope-from' +to the address you wish to use instead. + ** SQL mode *** New options `sql-port', `sql-connection-alist', `sql-send-terminator', diff --git a/lisp/ChangeLog b/lisp/ChangeLog index d4630d36691..4707834fe6b 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog @@ -1,3 +1,9 @@ +2012-09-04 Lars Ingebrigtsen + + * mail/smtpmail.el (smtpmail-send-it): Prefer the From: header + over `user-mail-address' for the SMTP MAIL FROM envelope. + (smtpmail-via-smtp): Ditto. + 2012-09-04 Dmitry Gutov * progmodes/ruby-mode.el: Clean up keybindings. diff --git a/lisp/mail/smtpmail.el b/lisp/mail/smtpmail.el index 804fe7a8798..69a405436a7 100644 --- a/lisp/mail/smtpmail.el +++ b/lisp/mail/smtpmail.el @@ -200,10 +200,10 @@ The list is in preference order.") ;; local binding in the mail buffer will take effect. (smtpmail-mail-address (or (and mail-specify-envelope-from (mail-envelope-from)) - (smtpmail-user-mail-address) - (let ((from (mail-fetch-field "from"))) + (let ((from (mail-fetch-field "from"))) (and from - (cadr (mail-extract-address-components 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)) @@ -653,12 +653,10 @@ Returns an error if the server cannot be contacted." (or smtpmail-mail-address (and mail-specify-envelope-from (mail-envelope-from)) - (smtpmail-user-mail-address) - ;; Fall back on the From: header as the envelope From - ;; address. (let ((from (mail-fetch-field "from"))) (and from - (cadr (mail-extract-address-components from)))))) + (cadr (mail-extract-address-components from)))) + (smtpmail-user-mail-address))) response-code process-buffer result -- 2.39.2