changeset 47837:b9705a05fa60

* mail/sendmail.el (mail-envelope-from): New option `header' to use RFC 2822 From: header as the envelope address. (mail-envelope-from): New function, this should be used instead of looking at the `mail-envelope-from' variable. (sendmail-send-it): Use it. * mail/smtpmail.el (smtpmail-via-smtp): Use it.
author Simon Josefsson <jas@extundo.com>
date Fri, 11 Oct 2002 02:27:09 +0000
parents 14b87846802e
children f7c5a53cf917
files lisp/mail/sendmail.el lisp/mail/smtpmail.el
diffstat 2 files changed, 12 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/lisp/mail/sendmail.el	Fri Oct 11 01:06:09 2002 +0000
+++ b/lisp/mail/sendmail.el	Fri Oct 11 02:27:09 2002 +0000
@@ -82,6 +82,7 @@
 content of `user-mail-address' is used."
   :version "21.1"
   :type '(choice (string :tag "From-name")
+		 (const :tag "Use From: header from message" header)
 		 (const :tag "Use `user-mail-address'" nil))
   :group 'sendmail)
 
@@ -774,6 +775,14 @@
 	    (progn
 	      (set-buffer-modified-p nil)
 	      (delete-auto-save-file-if-necessary t))))))
+
+(defun mail-envelope-from ()
+  "Return the envelope mail address to use when sending mail.
+This function uses `mail-envelope-from'."
+  (if (eq mail-envelope-from 'header)
+      (nth 1 (mail-extract-address-components
+ 	      (mail-fetch-field "From")))
+    mail-envelope-from))
 
 ;; This does the real work of sending a message via sendmail.
 ;; It is called via the variable send-mail-function.
@@ -822,7 +831,7 @@
 	;; local binding in the mail buffer will take effect.
 	(envelope-from
 	 (and mail-specify-envelope-from
-	      (or mail-envelope-from user-mail-address))))
+	      (or (mail-envelope-from) user-mail-address))))
     (unwind-protect
 	(save-excursion
 	  (set-buffer tembuf)
--- a/lisp/mail/smtpmail.el	Fri Oct 11 01:06:09 2002 +0000
+++ b/lisp/mail/smtpmail.el	Fri Oct 11 02:27:09 2002 +0000
@@ -540,6 +540,7 @@
 	(host (or smtpmail-smtp-server
 		  (error "`smtpmail-smtp-server' not defined")))
 	(port smtpmail-smtp-service)
+	(envelope-from (mail-envelope-from))
 	response-code
 	greeting
 	process-buffer
@@ -689,7 +690,7 @@
 		     "")))
 ;	      (smtpmail-send-command process (format "MAIL FROM:%s@%s" (user-login-name) (smtpmail-fqdn)))
 	      (smtpmail-send-command process (format "MAIL FROM: <%s>%s%s"
-						     (or mail-envelope-from
+						     (or envelope-from
 							 smtpmail-mail-address)
 						     size-part
 						     body-part))