unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: Simon Josefsson <jas@extundo.com>
Subject: [PATCH] Option to use From: header as envelope address
Date: Fri, 11 Oct 2002 04:27:44 +0200	[thread overview]
Message-ID: <ilu4rbt4sm7.fsf@latte.josefsson.org> (raw)

This adds an option to use the From: header as SMTP envelope address.
Note that the default is unchanged.  Thanks to Micha Wiedenmann who
tested it.  I have installed it.

2002-10-11  Simon Josefsson  <jas@extundo.com>

	* 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.

Index: sendmail.el
===================================================================
RCS file: /cvsroot/emacs/emacs/lisp/mail/sendmail.el,v
retrieving revision 1.258
diff -u -p -u -w -r1.258 sendmail.el
--- sendmail.el	23 Sep 2002 00:17:51 -0000	1.258
+++ sendmail.el	11 Oct 2002 02:17:42 -0000
@@ -82,6 +82,7 @@ If this is nil while `mail-specify-envel
 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)
 
@@ -775,6 +776,14 @@ the user from the mailer."
 	      (set-buffer-modified-p nil)
 	      (delete-auto-save-file-if-necessary t))))))
 \f
+(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))
+\f
 ;; This does the real work of sending a message via sendmail.
 ;; It is called via the variable send-mail-function.
 
@@ -822,7 +831,7 @@ external program defined by `sendmail-pr
 	;; 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)
Index: smtpmail.el
===================================================================
RCS file: /cvsroot/emacs/emacs/lisp/mail/smtpmail.el,v
retrieving revision 1.49
diff -u -p -r1.49 smtpmail.el
--- smtpmail.el	29 Sep 2002 03:19:35 -0000	1.49
+++ smtpmail.el	11 Oct 2002 02:18:33 -0000
@@ -540,6 +540,7 @@ This is relative to `smtpmail-queue-dir'
 	(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 @@ This is relative to `smtpmail-queue-dir'
 		     "")))
 ;	      (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))

                 reply	other threads:[~2002-10-11  2:27 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=ilu4rbt4sm7.fsf@latte.josefsson.org \
    --to=jas@extundo.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).