Gnus development mailing list
 help / color / mirror / Atom feed
* [Patch] Make message-user-mail-address use From header
@ 2003-02-24 21:13 Vasily Korytov
  2003-02-25  1:34 ` Jesper Harder
  0 siblings, 1 reply; 4+ messages in thread
From: Vasily Korytov @ 2003-02-24 21:13 UTC (permalink / raw)



[-- Attachment #1.1: Type: text/plain, Size: 391 bytes --]

I was annoyed, message-user-mail-address function uses the
user-mail-address variable only. It may be desireable in some cases to
have it derived from the From header (esp, in the
message-send-mail-with-sendmail function).

This patch seems to do it. But I'm really not sure, if it breaks
something.

BTW, maybe, we should add a check for Errors-To header prior to From?
Opinions?

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1.2: message.el.patch --]
[-- Type: text/x-patch, Size: 783 bytes --]

--- message.el~	Wed Feb  5 00:07:25 2003
+++ message.el	Tue Feb 25 00:01:30 2003
@@ -4473,10 +4473,15 @@
 
 (defun message-user-mail-address ()
   "Return the pertinent part of `user-mail-address'."
-  (when user-mail-address
-    (if (string-match " " user-mail-address)
-	(nth 1 (mail-extract-address-components user-mail-address))
-      user-mail-address)))
+  (let ((from (message-fetch-field "From")))
+    (if from
+	(if (string-match " " from)
+	    (nth 1 (mail-extract-address-components from))
+	  from)
+      (when user-mail-address
+	(if (string-match " " user-mail-address)
+	    (nth 1 (mail-extract-address-components user-mail-address))
+	  user-mail-address)))))
 
 (defun message-make-fqdn ()
   "Return user's fully qualified domain name."

[-- Attachment #1.3: Type: text/plain, Size: 141 bytes --]

-- 
       I accept RFC3156 and RFC1991-compatible encrypted mail.
PGP key fingerprint: 123A 7CCE 6E26 6233 0D87 E01A A0F8 3524 FCD8 1841

[-- Attachment #2: Type: application/pgp-signature, Size: 188 bytes --]

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [Patch] Make message-user-mail-address use From header
  2003-02-24 21:13 [Patch] Make message-user-mail-address use From header Vasily Korytov
@ 2003-02-25  1:34 ` Jesper Harder
  2003-02-25  3:33   ` Jesper Harder
  0 siblings, 1 reply; 4+ messages in thread
From: Jesper Harder @ 2003-02-25  1:34 UTC (permalink / raw)


deskpot@myrealbox.com (Vasily Korytov) writes:

> I was annoyed, message-user-mail-address function uses the
> user-mail-address variable only. It may be desireable in some cases to
> have it derived from the From header (esp, in the
> message-send-mail-with-sendmail function).

Two questions:

* Why not do it in `message-make-address' instead, which appears to be
  the function used directly in the sendmail related code?

* Is your diff against the most recent version of message.el?  Your
  patch doesn't apply cleanly.



^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [Patch] Make message-user-mail-address use From header
  2003-02-25  1:34 ` Jesper Harder
@ 2003-02-25  3:33   ` Jesper Harder
  2003-02-25  9:11     ` Vasily Korytov
  0 siblings, 1 reply; 4+ messages in thread
From: Jesper Harder @ 2003-02-25  3:33 UTC (permalink / raw)


[-- Attachment #1: Type: text/plain, Size: 757 bytes --]

Jesper Harder <harder@myrealbox.com> writes:

> deskpot@myrealbox.com (Vasily Korytov) writes:
>
>> I was annoyed, message-user-mail-address function uses the
>> user-mail-address variable only. It may be desireable in some cases to
>> have it derived from the From header (esp, in the
>> message-send-mail-with-sendmail function).
>
> Two questions:
>
> * Why not do it in `message-make-address' instead, which appears to be
>   the function used directly in the sendmail related code?

Following up to myself:

I think it would be cleaner not to overload the meaning of
`message-*-address', but use a different function/option for the
/envelope from/ instead.  

It's only because of the envelope from you want it, right?

How about something like this?


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: message.el.diff --]
[-- Type: text/x-patch, Size: 1633 bytes --]

--- gnus/lisp/message.el	Sun Feb 23 16:47:14 2003
+++ cvsgnus/lisp/message.el	Tue Feb 25 04:21:56 2003
@@ -636,6 +636,15 @@
   :group 'message-sending
   :type 'boolean)
 
+(defcustom message-sendmail-envelope-from nil
+  "*Envelope-from when sending mail with sendmail.
+If this is nil, use `user-mail-address'.  If it is the symbol
+`header', use the From: header of the message."
+  :type '(choice (string :tag "From name")
+		 (const :tag "Use From: header from message" header)
+		 (const :tag "Use `user-mail-address'" nil))
+  :group 'message-sending)
+
 ;; qmail-related stuff
 (defcustom message-qmail-inject-program "/var/qmail/bin/qmail-inject"
   "Location of the qmail-inject program."
@@ -3550,7 +3559,7 @@
 			;; But some systems are more broken with -f, so
 			;; we'll let users override this.
 			(if (null message-sendmail-f-is-evil)
-			    (list "-f" (message-make-address)))
+			    (list "-f" (message-sendmail-envelope-from)))
 			;; These mean "report errors by mail"
 			;; and "deliver in background".
 			(if (null message-interactive) '("-oem" "-odb"))
@@ -4506,6 +4515,16 @@
 	(nth 1 (mail-extract-address-components user-mail-address))
       user-mail-address)))
 
+(defun message-sendmail-envelope-from ()
+  "Return the envelope from."
+  (cond ((eq message-sendmail-envelope-from 'header)
+	 (nth 1 (mail-extract-address-components
+		 (message-fetch-field "from"))))
+	((stringp message-sendmail-envelope-from)
+	 message-sendmail-envelope-from)
+	(t
+	 (message-make-address))))
+
 (defun message-make-fqdn ()
   "Return user's fully qualified domain name."
   (let* ((system-name (system-name))

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [Patch] Make message-user-mail-address use From header
  2003-02-25  3:33   ` Jesper Harder
@ 2003-02-25  9:11     ` Vasily Korytov
  0 siblings, 0 replies; 4+ messages in thread
From: Vasily Korytov @ 2003-02-25  9:11 UTC (permalink / raw)


[-- Attachment #1: Type: text/plain, Size: 508 bytes --]

>>>>> "JH" == Jesper Harder writes:

 JH> I think it would be cleaner not to overload the meaning of
 JH> `message-*-address', but use a different function/option for the
 JH> /envelope from/ instead.  

Agreed.

 JH> It's only because of the envelope from you want it, right?

 JH> How about something like this?

Yes, thanks, that's really nice. =))

-- 
       I accept RFC3156 and RFC1991-compatible encrypted mail.
PGP key fingerprint: 123A 7CCE 6E26 6233 0D87 E01A A0F8 3524 FCD8 1841

[-- Attachment #2: Type: application/pgp-signature, Size: 188 bytes --]

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2003-02-25  9:11 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-02-24 21:13 [Patch] Make message-user-mail-address use From header Vasily Korytov
2003-02-25  1:34 ` Jesper Harder
2003-02-25  3:33   ` Jesper Harder
2003-02-25  9:11     ` Vasily Korytov

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 NNTP newsgroup(s).