Gnus development mailing list
 help / color / mirror / Atom feed
* smtpmail: MAIL FROM and `gnus-posting-styles'
@ 2002-09-17 14:37 Micha Wiedenmann
  2002-09-17 17:00 ` Simon Josefsson
  0 siblings, 1 reply; 10+ messages in thread
From: Micha Wiedenmann @ 2002-09-17 14:37 UTC (permalink / raw)


Hi,

when sendig a mail composed with `gnus-posting-styles' smtpmail uses
`user-mail-address' to determine "MAIL FROM:". Since
`gnus-posting-styles' already inserted "From: foo" this is confusing and
might be wrong. Is there a way to fix that behavior?

Is there somebody who uses several mail-addresse? How do you handle this
problem?

,----[ smtpmail.el ]
| 	      (smtpmail-send-command process (format "MAIL FROM: <%s>%s%s"
| 						     (or mail-envelope-from
| 							 ;; XEmacs:
| 							 (user-mail-address))
`----

TIA, Micha
-- 
Q: What have american beer and sex in a canoe in common?
A: Both are fucking close to water.



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

* Re: smtpmail: MAIL FROM and `gnus-posting-styles'
  2002-09-17 14:37 smtpmail: MAIL FROM and `gnus-posting-styles' Micha Wiedenmann
@ 2002-09-17 17:00 ` Simon Josefsson
  2002-09-17 20:47   ` Bjørn Mork
  0 siblings, 1 reply; 10+ messages in thread
From: Simon Josefsson @ 2002-09-17 17:00 UTC (permalink / raw)
  Cc: ding

Micha Wiedenmann <mw-u1@gmx.de> writes:

> Hi,
>
> when sendig a mail composed with `gnus-posting-styles' smtpmail uses
> `user-mail-address' to determine "MAIL FROM:". Since
> `gnus-posting-styles' already inserted "From: foo" this is confusing and
> might be wrong. Is there a way to fix that behavior?

Does it work to set user-mail-address in the posting style too?

> Is there somebody who uses several mail-addresse? How do you handle this
> problem?

I use several mail addresses but I only modify the From: header, not
the SMTP envelope sender.




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

* Re: smtpmail: MAIL FROM and `gnus-posting-styles'
  2002-09-17 17:00 ` Simon Josefsson
@ 2002-09-17 20:47   ` Bjørn Mork
  2002-09-19 14:25     ` Micha Wiedenmann
  0 siblings, 1 reply; 10+ messages in thread
From: Bjørn Mork @ 2002-09-17 20:47 UTC (permalink / raw)


Simon Josefsson <jas@extundo.com> writes:
> Micha Wiedenmann <mw-u1@gmx.de> writes:
>
>> when sendig a mail composed with `gnus-posting-styles' smtpmail uses
>> `user-mail-address' to determine "MAIL FROM:". Since
>> `gnus-posting-styles' already inserted "From: foo" this is confusing and
>> might be wrong. Is there a way to fix that behavior?
>
> Does it work to set user-mail-address in the posting style too?

Using 

  (address "bmork@dod.no")

in `gnus-posting-styles' works for me. This seems to change
`user-mail-address' locally. Just setting or editing "From:" does 
of course not. 


Bjørn
-- 
I mean, How can you be so malignant?  



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

* Re: smtpmail: MAIL FROM and `gnus-posting-styles'
  2002-09-17 20:47   ` Bjørn Mork
@ 2002-09-19 14:25     ` Micha Wiedenmann
  2002-09-19 17:30       ` Kai Großjohann
                         ` (2 more replies)
  0 siblings, 3 replies; 10+ messages in thread
From: Micha Wiedenmann @ 2002-09-19 14:25 UTC (permalink / raw)


Bjørn Mork writes:
>Simon Josefsson <jas@extundo.com> writes:
>> Micha Wiedenmann <mw-u1@gmx.de> writes:
>>
>>> when sendig a mail composed with `gnus-posting-styles' smtpmail uses
>>> `user-mail-address' to determine "MAIL FROM:". Since
>>> `gnus-posting-styles' already inserted "From: foo" this is confusing and
>>> might be wrong. Is there a way to fix that behavior?
>>
>> Does it work to set user-mail-address in the posting style too?

AFAICS it is not possible to set buffer-local variables from
`gnus-posting-styles' but I would need buffer-local
`user-mail-addresses' since I use several addresses.

Even if this would be possible I don't think this would help since I use
`message-send-mail-function' value: `gnus-agent-send-mail'. If I am
unplugged mail is stored in nndraft:queue and buffer-local settings
would also lost, wouldn't they?

I've two ideas:

· Why does smtpmail use mail-envelope-from but don't try to determine
  mail-from from :-) the mail?

· Is there a way to make buffer-local variables when the queue is send?

>Using
>
>  (address "bmork@dod.no")
>
>in `gnus-posting-styles' works for me. This seems to change
>`user-mail-address' locally. Just setting or editing "From:" does 
>of course not. 

Why of course not?

I use:

((".*"
  (name "Micha Wiedenmann")
  (address "foo@foo.de"))
 ((my-message-news-reply-p)
  (address "bar@bar.de")))

TIA, Micha
-- 
Sig lost. Core dumped.



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

* Re: smtpmail: MAIL FROM and `gnus-posting-styles'
  2002-09-19 14:25     ` Micha Wiedenmann
@ 2002-09-19 17:30       ` Kai Großjohann
  2002-09-21  0:42         ` Micha Wiedenmann
       [not found]       ` <mit.lcs.mail.ding/87r8fq18bs.fsf@ID-56226.news.dfncis.de>
  2002-09-24 11:44       ` Simon Josefsson
  2 siblings, 1 reply; 10+ messages in thread
From: Kai Großjohann @ 2002-09-19 17:30 UTC (permalink / raw)
  Cc: ding

Micha Wiedenmann <mw-u1@gmx.de> writes:

> Even if this would be possible I don't think this would help since I use
> `message-send-mail-function' value: `gnus-agent-send-mail'. If I am
> unplugged mail is stored in nndraft:queue and buffer-local settings
> would also lost, wouldn't they?

I think the X-Draft-From header is supposed to allow Gnus to recover
the right posting style.

kai
-- 
~/.signature is: umop 3p!sdn    (Frank Nobis)



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

* Re: smtpmail: MAIL FROM and `gnus-posting-styles'
  2002-09-19 17:30       ` Kai Großjohann
@ 2002-09-21  0:42         ` Micha Wiedenmann
  0 siblings, 0 replies; 10+ messages in thread
From: Micha Wiedenmann @ 2002-09-21  0:42 UTC (permalink / raw)


Kai Großjohann schrieb am 19.09.2002:

>Micha Wiedenmann <mw-u1@gmx.de> writes:
>
>> Even if this would be possible I don't think this would help since I use
>> `message-send-mail-function' value: `gnus-agent-send-mail'. If I am
>> unplugged mail is stored in nndraft:queue and buffer-local settings
>> would also lost, wouldn't they?
>
>I think the X-Draft-From header is supposed to allow Gnus to recover
>the right posting style.

X-Draft-From is used (set) in `gnus-draft-setup' I don't understand it
all but I trust you! :-) (used for posting styles).

I don't see, where it is used in `gnus-agent-send-mail' and I don't see
how the posting-styles set user-mail-address which is send by
`smtpmail-via-smtp'. 

X-Draft-From is not in Gnus 5.8.8 (but the statements above are about
recent CVS Oort.)

I have fixed my problem with I consider as a bug by fixing
`gnus-agent-send-mail' this function has not changed (v5.8.8 -> Oort)
yet.

,----[ gnus-agent.el ]
| (defun gnus-agent-send-mail ()
|   (if gnus-plugged
|       (progn
| 	;; restore user-mail-address from FROM header
| 	(let ((mail-envelope-from 
| 	       (nth 1 (mail-extract-address-components 
| 		       (message-fetch-field "From")))))
| 	  (funcall gnus-agent-send-mail-function)))
|     (goto-char (point-min))
|     (re-search-forward
|      (concat "^" (regexp-quote mail-header-separator) "\n"))
|     (replace-match "\n")
|     (gnus-agent-insert-meta-information 'mail)
|     (gnus-request-accept-article "nndraft:queue" nil t t)))
`----

This code makes sure that a message send via smtp uses the same
mail-address for SMTP:MAIL FROM %s as in the message From-header.

I had really strange problems with edebug and user-mail-address instead
of mail-envelope-from. While tracing through the let expression edebug
evaluated user-mail-address to "foo" bug `C-h v user-mail-address'
evalueted to bar. I thought I am silly. I didn't get a working version
with user-mail-address (I would not belive if I didn't tried!) Maybe
this was a side effekt from edebug and `q' (`q' runs `top-level', exit
debugging. If you have some time you could test it yourselve but I thing
mail-envelope-from is even better than user-mail-address.

HTH, Micha
-- 
"They were just sucked into space" -- Riker 
"Blown, sir" -- Data 
"Sorry, Data" -- Riker 
"Common mistake, sir" -- Data (Star Trek TNG: The Naked Now)



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

* Re: smtpmail: MAIL FROM and `gnus-posting-styles'
       [not found]       ` <mit.lcs.mail.ding/87r8fq18bs.fsf@ID-56226.news.dfncis.de>
@ 2002-09-23 19:20         ` Patrick J. LoPresti
  0 siblings, 0 replies; 10+ messages in thread
From: Patrick J. LoPresti @ 2002-09-23 19:20 UTC (permalink / raw)


Micha Wiedenmann <mw-u1@gmx.de> writes:

> AFAICS it is not possible to set buffer-local variables from
> `gnus-posting-styles' but I would need buffer-local
> `user-mail-addresses' since I use several addresses.

Below is the hack I use to set user-mail-address from the From header
dynamically.  Some broken software insists on using the envelope
sender (or Sender header) for replies, so I find it pays to forge
everything if you are going to forge anything.

It should be pretty easy to adapt this code for other sending methods.
(For qmail, you may need to add "-f <user-mail-address>" to the
qmail-inject line, for instance.)

 - Pat


(defun patl-send-mail-function ()
  ;; Save and restore user-mail-address
  (let ((user-mail-address user-mail-address))
    (message-send-mail-with-sendmail)))

(setq message-send-mail-function 'patl-send-mail-function)

(add-hook 'message-send-mail-hook
          (function
           (lambda ()
             (goto-char (point-min))
             (let ((from-header (mail-header 'from (mail-header-extract)))
                   from)
               (if (stringp from-header)
                   (setq from
                         (car-safe
                          (cdr-safe
                           (mail-extract-address-components from-header)))))
               (if from
                   (setq user-mail-address from))))))



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

* Re: smtpmail: MAIL FROM and `gnus-posting-styles'
  2002-09-19 14:25     ` Micha Wiedenmann
  2002-09-19 17:30       ` Kai Großjohann
       [not found]       ` <mit.lcs.mail.ding/87r8fq18bs.fsf@ID-56226.news.dfncis.de>
@ 2002-09-24 11:44       ` Simon Josefsson
  2002-09-24 16:59         ` Micha Wiedenmann
  2 siblings, 1 reply; 10+ messages in thread
From: Simon Josefsson @ 2002-09-24 11:44 UTC (permalink / raw)
  Cc: ding

Micha Wiedenmann <mw-u1@gmx.de> writes:

> Bjørn Mork writes:
>>Simon Josefsson <jas@extundo.com> writes:
>>> Micha Wiedenmann <mw-u1@gmx.de> writes:
>>>
>>>> when sendig a mail composed with `gnus-posting-styles' smtpmail uses
>>>> `user-mail-address' to determine "MAIL FROM:". Since
>>>> `gnus-posting-styles' already inserted "From: foo" this is confusing and
>>>> might be wrong. Is there a way to fix that behavior?
>>>
>>> Does it work to set user-mail-address in the posting style too?
>
> AFAICS it is not possible to set buffer-local variables from
> `gnus-posting-styles' but I would need buffer-local
> `user-mail-addresses' since I use several addresses.

Ah.  Hm.  But can't you set the global variable?  If you always use
posting styles, the global variable will have the right value.  If you
don't always use posting, perhaps using a message-sent-hook that
restores the global variable could work.

> Even if this would be possible I don't think this would help since I use
> `message-send-mail-function' value: `gnus-agent-send-mail'. If I am
> unplugged mail is stored in nndraft:queue and buffer-local settings
> would also lost, wouldn't they?

I think posting styles are supposed to be applied even when the
message is read from the nndraft:queue group, using the X-Draft-From:
header.

> I've two ideas:
>
> · Why does smtpmail use mail-envelope-from but don't try to determine
>   mail-from from :-) the mail?

Well, because the SMTP envelope header is different from the RFC822
header.  Perhaps there could be a speciel smtpmail.el feature that
used the From: address as SMTP envelope address?  This sounds trivial
to implement and could perhaps be generally useful.  What do you
think?

Hm.  Extending `mail-envelope-from' seems like the right thing.  What
do you think of the following?  (The second :type alternative,
`header', is new, the rest is unchanged.)

(defcustom mail-envelope-from nil
  "*If non-nil, designate the envelope-from address when sending mail.
If this is nil while `mail-specify-envelope-from' is non-nil, the
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)

> · Is there a way to make buffer-local variables when the queue is send?

I don't know.




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

* Re: smtpmail: MAIL FROM and `gnus-posting-styles'
  2002-09-24 11:44       ` Simon Josefsson
@ 2002-09-24 16:59         ` Micha Wiedenmann
  2002-09-24 20:42           ` Simon Josefsson
  0 siblings, 1 reply; 10+ messages in thread
From: Micha Wiedenmann @ 2002-09-24 16:59 UTC (permalink / raw)


* Simon Josefsson <jas@extundo.com> writes:
>Micha Wiedenmann <mw-u1@gmx.de> writes:
>> Bjørn Mork writes:
>>>Simon Josefsson <jas@extundo.com> writes:
>>>> Micha Wiedenmann <mw-u1@gmx.de> writes:
>>>>
>>>>> when sendig a mail composed with `gnus-posting-styles' smtpmail uses
>>>>> `user-mail-address' to determine "MAIL FROM:". Since
>>>>> `gnus-posting-styles' already inserted "From: foo" this is confusing and
>>>>> might be wrong. Is there a way to fix that behavior?
>>>>
>>>> Does it work to set user-mail-address in the posting style too?
>>
>> AFAICS it is not possible to set buffer-local variables from
>> `gnus-posting-styles' but I would need buffer-local
>> `user-mail-addresses' since I use several addresses.
>
>Ah.  Hm.  But can't you set the global variable?  If you always use
>posting styles, the global variable will have the right value.  If you
>don't always use posting, perhaps using a message-sent-hook that
>restores the global variable could work.
>
>> Even if this would be possible I don't think this would help since I use
>> `message-send-mail-function' value: `gnus-agent-send-mail'. If I am
>> unplugged mail is stored in nndraft:queue and buffer-local settings
>> would also lost, wouldn't they?
>
>I think posting styles are supposed to be applied even when the
>message is read from the nndraft:queue group, using the X-Draft-From:
>header.

I checked the following with Gnus v5.8.8 and a recent CVS Oort (and gnus-agent):

· Create a message. Make sure posting-styles applied.
· Change the From: into something differen
· Send the Message (unplugged -> queue)
· Go plugged and send the message
· my:send-message told me that the posing-styles were applied (even in
  5.8.8) 

The settup:

,----[ .gnus ]
| (setq gnus-select-method '(nntp "news.cis.dfn.de"))
| 
| (setq gnus-posting-styles
|      '((".*"
| 	(name "Micha Wiedenmann")
| 	(address "mw-u1-dont-trust-posting-styles@gmx.de"))))
| 
| (setq gnus-plugged nil)
| (gnus-agentize)
`----

,----[ *scratch* ]
| (setq gnus-agent-send-mail-function 'my:send-message)
| (defun my:send-message ()
|   (message (user-mail-address)))
`----

So the problem is more precise: Wenn From is changed with respect to the
value gnus-posting-styles would applie the changed From doesn't have any
influence on MAIL FROM.

IMHO This is a serious problem for any user who don't think about such
side effects. This should either be documented (but where?) or changed.

>> I've two ideas:
>>
>> · Why does smtpmail use mail-envelope-from but don't try to determine
>>   mail-from from :-) the mail?
>
>Well, because the SMTP envelope header is different from the RFC822
>header.  Perhaps there could be a speciel smtpmail.el feature that
>used the From: address as SMTP envelope address?  This sounds trivial
>to implement and could perhaps be generally useful.  What do you
>think?

Yes this sounds really great.

>Hm.  Extending `mail-envelope-from' seems like the right thing.  What
>do you think of the following?  (The second :type alternative,
>`header', is new, the rest is unchanged.)
>
>(defcustom mail-envelope-from nil
>  "*If non-nil, designate the envelope-from address when sending mail.
>If this is nil while `mail-specify-envelope-from' is non-nil, the
>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)

I think this is a good solution for message-send-via-smtp! This is
simple, elegant and straightforward! (I often tend to see things to
difficult :-)

Thank you very much, Micha
-- 
Writing science fiction for about a penny a word is no way to make a living. If
you really want to make a million, the quickest way is to start your own
religion.               -- L. Ron Hubbard, SF author and founder of Scientology



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

* Re: smtpmail: MAIL FROM and `gnus-posting-styles'
  2002-09-24 16:59         ` Micha Wiedenmann
@ 2002-09-24 20:42           ` Simon Josefsson
  0 siblings, 0 replies; 10+ messages in thread
From: Simon Josefsson @ 2002-09-24 20:42 UTC (permalink / raw)
  Cc: ding

Micha Wiedenmann <mw-u1@gmx.de> writes:

> So the problem is more precise: Wenn From is changed with respect to the
> value gnus-posting-styles would applie the changed From doesn't have any
> influence on MAIL FROM.

Yup.  This is the intended behaviour, I think.  Some people might not
like it though...

> I think this is a good solution for message-send-via-smtp! This is
> simple, elegant and straightforward! (I often tend to see things to
> difficult :-)

...so they can use the following patch and customize
`mail-envelope-from' to the symbol header.  Please test it, against
s{end,mtp}mail.el in Emacs CVS.

Index: sendmail.el
===================================================================
RCS file: /cvsroot/emacs/emacs/lisp/mail/sendmail.el,v
retrieving revision 1.257
diff -u -p -u -w -r1.257 sendmail.el
--- sendmail.el	2 Sep 2002 17:24:54 -0000	1.257
+++ sendmail.el	24 Sep 2002 20:38:00 -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,13 @@ 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)
+      (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.
 
@@ -821,7 +829,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.48
diff -u -p -u -w -r1.48 smtpmail.el
--- smtpmail.el	12 Sep 2002 06:03:03 -0000	1.48
+++ smtpmail.el	24 Sep 2002 20:38:19 -0000
@@ -689,7 +689,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 (mail-envelope-from)
 							 smtpmail-mail-address)
 						     size-part
 						     body-part))




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

end of thread, other threads:[~2002-09-24 20:42 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-09-17 14:37 smtpmail: MAIL FROM and `gnus-posting-styles' Micha Wiedenmann
2002-09-17 17:00 ` Simon Josefsson
2002-09-17 20:47   ` Bjørn Mork
2002-09-19 14:25     ` Micha Wiedenmann
2002-09-19 17:30       ` Kai Großjohann
2002-09-21  0:42         ` Micha Wiedenmann
     [not found]       ` <mit.lcs.mail.ding/87r8fq18bs.fsf@ID-56226.news.dfncis.de>
2002-09-23 19:20         ` Patrick J. LoPresti
2002-09-24 11:44       ` Simon Josefsson
2002-09-24 16:59         ` Micha Wiedenmann
2002-09-24 20:42           ` Simon Josefsson

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