From mboxrd@z Thu Jan 1 00:00:00 1970 Path: main.gmane.org!not-for-mail From: Simon Josefsson Newsgroups: gmane.emacs.devel Subject: [PATCH] Option to use From: header as envelope address Date: Fri, 11 Oct 2002 04:27:44 +0200 Sender: emacs-devel-admin@gnu.org Message-ID: NNTP-Posting-Host: localhost.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: main.gmane.org 1034344085 21622 127.0.0.1 (11 Oct 2002 13:48:05 GMT) X-Complaints-To: usenet@main.gmane.org NNTP-Posting-Date: Fri, 11 Oct 2002 13:48:05 +0000 (UTC) Return-path: Original-Received: from quimby.gnus.org ([80.91.224.244]) by main.gmane.org with esmtp (Exim 3.35 #1 (Debian)) id 180090-0005bn-00 for ; Fri, 11 Oct 2002 15:47:58 +0200 Original-Received: from monty-python.gnu.org ([199.232.76.173]) by quimby.gnus.org with esmtp (Exim 3.12 #1 (Debian)) id 1800y2-0002wR-00 for ; Fri, 11 Oct 2002 16:40:42 +0200 Original-Received: from localhost ([127.0.0.1] helo=monty-python.gnu.org) by monty-python.gnu.org with esmtp (Exim 4.10) id 18008J-0004BO-00; Fri, 11 Oct 2002 09:47:15 -0400 Original-Received: from list by monty-python.gnu.org with tmda-scanned (Exim 4.10) id 18007C-0003ru-00 for emacs-devel@gnu.org; Fri, 11 Oct 2002 09:46:06 -0400 Original-Received: from mail by monty-python.gnu.org with spam-scanned (Exim 4.10) id 18007A-0003rT-00 for emacs-devel@gnu.org; Fri, 11 Oct 2002 09:46:06 -0400 Original-Received: from gnudist.gnu.org ([199.232.41.7]) by monty-python.gnu.org with esmtp (Exim 4.10) id 17zyvq-0006Gf-00 for emacs-devel@gnu.org; Fri, 11 Oct 2002 08:30:18 -0400 Original-Received: from 178.230.13.217.in-addr.dgcsystems.net ([217.13.230.178] helo=yxa.extundo.com) by gnudist.gnu.org with esmtp (Exim 4.10) id 17zpcB-00081R-00 for emacs-devel@gnu.org; Thu, 10 Oct 2002 22:33:23 -0400 Original-Received: from latte.josefsson.org (yxa.extundo.com [217.13.230.178]) (authenticated bits=0) by yxa.extundo.com (8.12.6/8.12.6) with ESMTP id g9B2RjFu032216 (version=TLSv1/SSLv3 cipher=EDH-RSA-DES-CBC3-SHA bits=168 verify=NO) for ; Fri, 11 Oct 2002 04:27:46 +0200 Original-To: emacs-devel@gnu.org X-Hashcash: 0:021011:emacs-devel@gnu.org:a051c9b391992854 User-Agent: Gnus/5.090008 (Oort Gnus v0.08) Emacs/21.2 (i386-debian-linux-gnu) Errors-To: emacs-devel-admin@gnu.org X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.0.11 Precedence: bulk List-Help: List-Post: List-Subscribe: , List-Id: Emacs development discussions. List-Unsubscribe: , List-Archive: Xref: main.gmane.org gmane.emacs.devel:8524 X-Report-Spam: http://spam.gmane.org/gmane.emacs.devel:8524 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 * 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)))))) +(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 @@ 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))