unofficial mirror of notmuch@notmuchmail.org
 help / color / mirror / code / Atom feed
* [BUG] notmuch-emacs: spoils sendmail -f with emacs 27 commit 3a59cc84069376802ba8fd731b524d78db58262c and later
@ 2019-12-01 17:10 Gregor Zattler
  2019-12-03 18:43 ` David Edmondson
  0 siblings, 1 reply; 9+ messages in thread
From: Gregor Zattler @ 2019-12-01 17:10 UTC (permalink / raw)
  To: notmuch; +Cc: Stefan Monnier

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

[@Stefan: FYI]
Dear notmuch developers,

I use notmuch-emacs configured with
(setq mail-specify-envelope-from t)
(setq mail-envelope-from 'header)
(setq send-mail-function 'sendmail-send-it)

this should/used to invoke sendmail (in my case exim4) with the email
address given in the From: header of the message buffer as
argument to sendmails -f option.

Since emacs 27 commit 3a59cc84069376802ba8fd731b524d78db58262c

     3a59cc84069376802ba8fd731b524d78db58262c
     Author:     Stefan Monnier <monnier@iro.umontreal.ca>
     AuthorDate: Tue Jul 30 16:37:01 2019 -0400
     Commit:     Stefan Monnier <monnier@iro.umontreal.ca>
     CommitDate: Tue Jul 30 16:37:01 2019 -0400

     Parent:     add146f09f * lisp/bindings.el (mode-line-defining-kbd-macro): New defvar.
     Contained:  master
     Follows:    emacs-26.1 (6691)

     * lisp/gnus/message.el: Reduce redundancy with send-mail-function

     (message-send-mail-function) <function>: Remove `local-library` tests
     for libs distributed with Emacs.
     (message-use-send-mail-function): New function.
     (message-default-send-mail-function): Default to it, and remove cases
     already handled by it.
     (message--default-send-mail-function): New function.
     (message-send-mail-function) <variable>: Use it as new default.
     (message-sendmail-f-is-evil): Obey mail-specify-envelope-from if available.
     (message-check, message-with-reply-buffer): Use `declare`.
     (message-smtpmail-send-it): smtpmail accepts mail-header-separator,
     so simplify and declare obsolete.
     (message-send-mail-with-mailclient): Declare obsolete.
     (message-check-news-body-syntax): Don't presume that the checksum is
     a fixnum.


this actually invokes sendmail -f with an address derived from the
EMAIL environment variable.


It took me some time to understand, that there is no problem with
compose-mail/message-send-and-exit which are bound to ^X m and ^C
^C respectively within a barely configured emacs which I used for
testing.
If instead notmuch is loaded compose-mail/message-send-and-exit
and notmuch-mua-new-mail/notmuch-mua-send behave different.

With this command (with test.el as attached):

~/src/emacs/src/emacs -Q -nw -l /tmp/test.el

compose-mail/message-send-and-exit rightly show
-f example@example.org in the file /tmp/result (and then there is
an error because the notmuch commands are not known).

While this command

~/src/emacs/src/emacs -Q -nw -L ~/src/notmuch/emacs/ --eval "(require 'notmuch)" -f notmuch -l /tmp/test.el

wrongly show some other value for -f, depending on your EMAIL
environment variable, for both compose-mail/message-send-and-exit
and notmuch-mua-new-mail/notmuch-mua-send.


I read the code but I have no idea why and how to debug this.

Ciao; Gregor
--
 -... --- .-. . -.. ..--.. ...-.-


[-- Attachment #2: test.el --]
[-- Type: application/emacs-lisp, Size: 941 bytes --]

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

* Re: [BUG] notmuch-emacs: spoils sendmail -f with emacs 27 commit 3a59cc84069376802ba8fd731b524d78db58262c and later
  2019-12-01 17:10 [BUG] notmuch-emacs: spoils sendmail -f with emacs 27 commit 3a59cc84069376802ba8fd731b524d78db58262c and later Gregor Zattler
@ 2019-12-03 18:43 ` David Edmondson
  2019-12-03 19:15   ` Gregor Zattler
  2019-12-03 20:39   ` Stefan Monnier
  0 siblings, 2 replies; 9+ messages in thread
From: David Edmondson @ 2019-12-03 18:43 UTC (permalink / raw)
  To: Gregor Zattler, notmuch; +Cc: Stefan Monnier

On Sunday, 2019-12-01 at 18:10:59 +01, Gregor Zattler wrote:

> [@Stefan: FYI]
> Dear notmuch developers,
>
> I use notmuch-emacs configured with
> (setq mail-specify-envelope-from t)
> (setq mail-envelope-from 'header)
> (setq send-mail-function 'sendmail-send-it)
>
> this should/used to invoke sendmail (in my case exim4) with the email
> address given in the From: header of the message buffer as
> argument to sendmails -f option.

Wow, this was, err, “interesting”.

Comments below.

> Since emacs 27 commit 3a59cc84069376802ba8fd731b524d78db58262c
>
>      3a59cc84069376802ba8fd731b524d78db58262c
>      Author:     Stefan Monnier <monnier@iro.umontreal.ca>
>      AuthorDate: Tue Jul 30 16:37:01 2019 -0400
>      Commit:     Stefan Monnier <monnier@iro.umontreal.ca>
>      CommitDate: Tue Jul 30 16:37:01 2019 -0400
>
>      Parent:     add146f09f * lisp/bindings.el (mode-line-defining-kbd-macro): New defvar.
>      Contained:  master
>      Follows:    emacs-26.1 (6691)
>
>      * lisp/gnus/message.el: Reduce redundancy with send-mail-function
>
>      (message-send-mail-function) <function>: Remove `local-library` tests
>      for libs distributed with Emacs.
>      (message-use-send-mail-function): New function.
>      (message-default-send-mail-function): Default to it, and remove cases
>      already handled by it.
>      (message--default-send-mail-function): New function.
>      (message-send-mail-function) <variable>: Use it as new default.
>      (message-sendmail-f-is-evil): Obey mail-specify-envelope-from if available.
>      (message-check, message-with-reply-buffer): Use `declare`.
>      (message-smtpmail-send-it): smtpmail accepts mail-header-separator,
>      so simplify and declare obsolete.
>      (message-send-mail-with-mailclient): Declare obsolete.
>      (message-check-news-body-syntax): Don't presume that the checksum is
>      a fixnum.
>
>
> this actually invokes sendmail -f with an address derived from the
> EMAIL environment variable.
>
>
> It took me some time to understand, that there is no problem with
> compose-mail/message-send-and-exit which are bound to ^X m and ^C
> ^C respectively within a barely configured emacs which I used for
> testing.
> If instead notmuch is loaded compose-mail/message-send-and-exit
> and notmuch-mua-new-mail/notmuch-mua-send behave different.
>
> With this command (with test.el as attached):
>
> ~/src/emacs/src/emacs -Q -nw -l /tmp/test.el
>
> compose-mail/message-send-and-exit rightly show
> -f example@example.org in the file /tmp/result (and then there is
> an error because the notmuch commands are not known).
>
> While this command
>
> ~/src/emacs/src/emacs -Q -nw -L ~/src/notmuch/emacs/ --eval "(require 'notmuch)" -f notmuch -l /tmp/test.el
>
> wrongly show some other value for -f, depending on your EMAIL
> environment variable, for both compose-mail/message-send-and-exit
> and notmuch-mua-new-mail/notmuch-mua-send.
>
>
> I read the code but I have no idea why and how to debug this.
>
> Ciao; Gregor
> --
>  -... --- .-. . -.. ..--.. ...-.-
>
> (find-file "/tmp/sent")
> (insert "empty")
> (kill-region (point-min) (point-max))
> (write-file "/tmp/sent")
> (kill-buffer)
>
> (find-file "/tmp/result")
> (kill-region (point-min) (point-max))
> (write-file "/tmp/result")
> (kill-buffer)
>
> (find-file "/tmp/show-sendmail-args.sh")
> (kill-region (point-min) (point-max))
> (insert "#!/bin/sh
> echo $* >> /tmp/result")
> (write-file "/tmp/show-sendmail-args.sh")
> (chmod "/tmp/show-sendmail-args.sh" 448)
>
> (setq sendmail-program "/tmp/show-sendmail-args.sh")
> (setq mail-specify-envelope-from t)
> (setq mail-envelope-from 'header)
> (setq send-mail-function 'sendmail-send-it)
>
> (compose-mail "Echo Mail Server <echo@univie.ac.at>" "test"
>                '((From: . "example@example.org")))

This example, and the one below, are broken - you can't use “From:”
here, it has to be “From”. Changing that doesn't fix it, though.

> (message-send-and-exit)
>
> (notmuch-mua-mail "Echo Mail Server <echo@univie.ac.at>" "test"
>                '((From: . "example@example.org")))
> (notmuch-mua-send-and-exit)
>
> (save-buffers-kill-terminal)

As best I can determine, this relates to the order in which things are
loaded.

If you load message.el before setting `mail-specify-envelope-from',
things are broken (sorry for the long lines):

disaster-area ~/s/emacs % ./src/emacs -Q -nw -batch --eval "(progn (require 'message) (setq mail-specify-envelope-from t mail-envelope-from 'header) (message \"%s\" message-sendmail-envelope-from))"
nil
disaster-area ~/s/emacs % 

...but if you load it after, things work fine:

disaster-area ~/s/emacs % ./src/emacs -Q -nw -batch --eval "(progn (setq mail-specify-envelope-from t mail-envelope-from 'header) (require 'message) (message \"%s\" message-sendmail-envelope-from))"
header
disaster-area ~/s/emacs %

This doesn't appear to be new behaviour - 26.1 does the same.

This is related to the way that `message-sendmail-envelope-from' is
initialised from `mail-envelope-from', and it's
`message-sendmail-envelope-from' that matters, because you end up in
`message-send-mail-with-sendmail'.

message.el is being loaded by “(require 'notmuch)” in your example,
which is happening before `mail-specify-envelope-from' is set, so you
see the failure mode described.

The example you provided is obviously contrived to show the problem -
are you hitting it in normal use?

dme.
-- 
Does everyone stare the way I do?

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

* Re: [BUG] notmuch-emacs: spoils sendmail -f with emacs 27 commit 3a59cc84069376802ba8fd731b524d78db58262c and later
  2019-12-03 18:43 ` David Edmondson
@ 2019-12-03 19:15   ` Gregor Zattler
  2019-12-03 19:42     ` David Edmondson
  2019-12-04 12:03     ` David Edmondson
  2019-12-03 20:39   ` Stefan Monnier
  1 sibling, 2 replies; 9+ messages in thread
From: Gregor Zattler @ 2019-12-03 19:15 UTC (permalink / raw)
  To: David Edmondson, notmuch; +Cc: Stefan Monnier

Hi David,
* David Edmondson <dme@dme.org> [2019-12-03; 18:43]:
> On Sunday, 2019-12-01 at 18:10:59 +01, Gregor Zattler wrote:
>> I use notmuch-emacs configured with
>> (setq mail-specify-envelope-from t)
>> (setq mail-envelope-from 'header)
>> (setq send-mail-function 'sendmail-send-it)
>>
>> this should/used to invoke sendmail (in my case exim4) with the email
>> address given in the From: header of the message buffer as
>> argument to sendmails -f option.
>
> Wow, this was, err, “interesting”.
>
> Comments below.
>
>> Since emacs 27 commit 3a59cc84069376802ba8fd731b524d78db58262c
>>
>>      3a59cc84069376802ba8fd731b524d78db58262c
>>      Author:     Stefan Monnier <monnier@iro.umontreal.ca>
>>      AuthorDate: Tue Jul 30 16:37:01 2019 -0400
>>      Commit:     Stefan Monnier <monnier@iro.umontreal.ca>
>>      CommitDate: Tue Jul 30 16:37:01 2019 -0400
>>
>>      Parent:     add146f09f * lisp/bindings.el (mode-line-defining-kbd-macro): New defvar.
>>      Contained:  master
>>      Follows:    emacs-26.1 (6691)
>>
>>      * lisp/gnus/message.el: Reduce redundancy with send-mail-function
>>
>>      (message-send-mail-function) <function>: Remove `local-library` tests
>>      for libs distributed with Emacs.
>>      (message-use-send-mail-function): New function.
>>      (message-default-send-mail-function): Default to it, and remove cases
>>      already handled by it.
>>      (message--default-send-mail-function): New function.
>>      (message-send-mail-function) <variable>: Use it as new default.
>>      (message-sendmail-f-is-evil): Obey mail-specify-envelope-from if available.
>>      (message-check, message-with-reply-buffer): Use `declare`.
>>      (message-smtpmail-send-it): smtpmail accepts mail-header-separator,
>>      so simplify and declare obsolete.
>>      (message-send-mail-with-mailclient): Declare obsolete.
>>      (message-check-news-body-syntax): Don't presume that the checksum is
>>      a fixnum.
>>
>>
>> this actually invokes sendmail -f with an address derived from the
>> EMAIL environment variable.
>>
>>
>> It took me some time to understand, that there is no problem with
>> compose-mail/message-send-and-exit which are bound to ^X m and ^C
>> ^C respectively within a barely configured emacs which I used for
>> testing.
>> If instead notmuch is loaded compose-mail/message-send-and-exit
>> and notmuch-mua-new-mail/notmuch-mua-send behave different.
>>
>> With this command (with test.el as attached):
>>
>> ~/src/emacs/src/emacs -Q -nw -l /tmp/test.el
>>
>> compose-mail/message-send-and-exit rightly show
>> -f example@example.org in the file /tmp/result (and then there is
>> an error because the notmuch commands are not known).
>>
>> While this command
>>
>> ~/src/emacs/src/emacs -Q -nw -L ~/src/notmuch/emacs/ --eval "(require 'notmuch)" -f notmuch -l /tmp/test.el
>>
>> wrongly show some other value for -f, depending on your EMAIL
>> environment variable, for both compose-mail/message-send-and-exit
>> and notmuch-mua-new-mail/notmuch-mua-send.

>> (find-file "/tmp/sent")
>> (insert "empty")
>> (kill-region (point-min) (point-max))
>> (write-file "/tmp/sent")
>> (kill-buffer)
>>
>> (find-file "/tmp/result")
>> (kill-region (point-min) (point-max))
>> (write-file "/tmp/result")
>> (kill-buffer)
>>
>> (find-file "/tmp/show-sendmail-args.sh")
>> (kill-region (point-min) (point-max))
>> (insert "#!/bin/sh
>> echo $* >> /tmp/result")
>> (write-file "/tmp/show-sendmail-args.sh")
>> (chmod "/tmp/show-sendmail-args.sh" 448)
>>
>> (setq sendmail-program "/tmp/show-sendmail-args.sh")
>> (setq mail-specify-envelope-from t)
>> (setq mail-envelope-from 'header)
>> (setq send-mail-function 'sendmail-send-it)
>>
>> (compose-mail "Echo Mail Server <echo@univie.ac.at>" "test"
>>                '((From: . "example@example.org")))
>
> This example, and the one below, are broken - you can't use “From:”
> here, it has to be “From”. Changing that doesn't fix it, though.

OK, thanks.

>> (message-send-and-exit)
>>
>> (notmuch-mua-mail "Echo Mail Server <echo@univie.ac.at>" "test"
>>                '((From: . "example@example.org")))
>> (notmuch-mua-send-and-exit)
>>
>> (save-buffers-kill-terminal)
>
> As best I can determine, this relates to the order in which things are
> loaded.
>
> If you load message.el before setting `mail-specify-envelope-from',
> things are broken (sorry for the long lines):
>
> disaster-area ~/s/emacs % ./src/emacs -Q -nw -batch --eval "(progn (require 'message) (setq mail-specify-envelope-from t mail-envelope-from 'header) (message \"%s\" message-sendmail-envelope-from))"
> nil
> disaster-area ~/s/emacs % 
>
> ...but if you load it after, things work fine:
>
> disaster-area ~/s/emacs % ./src/emacs -Q -nw -batch --eval "(progn (setq mail-specify-envelope-from t mail-envelope-from 'header) (require 'message) (message \"%s\" message-sendmail-envelope-from))"
> header
> disaster-area ~/s/emacs %
>
> This doesn't appear to be new behaviour - 26.1 does the same.

this is astonishing, since my test script behaves different with
emacs build with different last commits!?

> This is related to the way that `message-sendmail-envelope-from' is
> initialised from `mail-envelope-from', and it's
> `message-sendmail-envelope-from' that matters, because you end up in
> `message-send-mail-with-sendmail'.

At the moment I cannot follow...

> message.el is being loaded by “(require 'notmuch)” in your example,
> which is happening before `mail-specify-envelope-from' is set, so you
> see the failure mode described.

... but in my example the setq forms precede every call to
message/notmuch (as in your example)!? [And in my emacs
configuration the customizations made with emacs' customization
interface (among others the three variables which are setq in my
test script) are loaded before almost anything else, especially
message/notmuch, see below]

> The example you provided is obviously contrived to show the problem -
> are you hitting it in normal use?

Absolutely.  I struggle with this at least since 2nd of August and have
reproduced this behaviour dozens of times.  It took my several
attempts to isolate the problem.

I use https://github.com/xundeenergie/exim4-multiaccount version
1.57 as of 2018-06-05 in order to send emails through different
smarthosts.

I do this every day and with emacs from sources newer than commit
01739625704aaaea6831cef459a4a53171689513 I'm e.g. not able to send
emails with my work email address ot to this mailing list.  This
is especially annoying since sending fails silently.  So
relatively important emails as e.g. announcements of downtimes did
not reach their intended audience.


The whole thing is above my elisp knowledge.  Is it possible you
describe something which is not the problem I described?

Ciao; Gregor
-- 
 -... --- .-. . -.. ..--.. ...-.-

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

* Re: [BUG] notmuch-emacs: spoils sendmail -f with emacs 27 commit 3a59cc84069376802ba8fd731b524d78db58262c and later
  2019-12-03 19:15   ` Gregor Zattler
@ 2019-12-03 19:42     ` David Edmondson
  2019-12-04 12:03     ` David Edmondson
  1 sibling, 0 replies; 9+ messages in thread
From: David Edmondson @ 2019-12-03 19:42 UTC (permalink / raw)
  To: Gregor Zattler, notmuch; +Cc: Stefan Monnier

On Tuesday, 2019-12-03 at 20:15:02 +01, Gregor Zattler wrote:

>> As best I can determine, this relates to the order in which things are
>> loaded.
>>
>> If you load message.el before setting `mail-specify-envelope-from',
>> things are broken (sorry for the long lines):
>>
>> disaster-area ~/s/emacs % ./src/emacs -Q -nw -batch --eval "(progn (require 'message) (setq mail-specify-envelope-from t mail-envelope-from 'header) (message \"%s\" message-sendmail-envelope-from))"
>> nil
>> disaster-area ~/s/emacs % 
>>
>> ...but if you load it after, things work fine:
>>
>> disaster-area ~/s/emacs % ./src/emacs -Q -nw -batch --eval "(progn (setq mail-specify-envelope-from t mail-envelope-from 'header) (require 'message) (message \"%s\" message-sendmail-envelope-from))"
>> header
>> disaster-area ~/s/emacs %
>>
>> This doesn't appear to be new behaviour - 26.1 does the same.
>
> this is astonishing, since my test script behaves different with
> emacs build with different last commits!?

There may well be other layers of complication :-)

>> This is related to the way that `message-sendmail-envelope-from' is
>> initialised from `mail-envelope-from', and it's
>> `message-sendmail-envelope-from' that matters, because you end up in
>> `message-send-mail-with-sendmail'.
>
> At the moment I cannot follow...

At least in 27, I don't think that you end up using `sendmail-send-it',
because I don't believe that message.el is looking at
`send-mail-function'.

>> message.el is being loaded by “(require 'notmuch)” in your example,
>> which is happening before `mail-specify-envelope-from' is set, so you
>> see the failure mode described.
>
> ... but in my example the setq forms precede every call to
> message/notmuch (as in your example)!?

That's not the case. Your example is:

> ~/src/emacs/src/emacs -Q -nw -L ~/src/notmuch/emacs/ --eval "(require 'notmuch)" -f notmuch -l /tmp/test.el

This loads (via the require) notmuch.el, and consequently message.el,
*before* it loads /tmp/test.el, so the setq calls happen after
message.el has been loaded.

> [And in my emacs configuration the customizations made with emacs'
> customization interface (among others the three variables which are
> setq in my test script) are loaded before almost anything else,
> especially message/notmuch, see below]
>
>> The example you provided is obviously contrived to show the problem -
>> are you hitting it in normal use?
>
> Absolutely.  I struggle with this at least since 2nd of August and have
> reproduced this behaviour dozens of times.  It took my several
> attempts to isolate the problem.
>
> I use https://github.com/xundeenergie/exim4-multiaccount version
> 1.57 as of 2018-06-05 in order to send emails through different
> smarthosts.
>
> I do this every day and with emacs from sources newer than commit
> 01739625704aaaea6831cef459a4a53171689513 I'm e.g. not able to send
> emails with my work email address ot to this mailing list.  This
> is especially annoying since sending fails silently.  So
> relatively important emails as e.g. announcements of downtimes did
> not reach their intended audience.
>
> The whole thing is above my elisp knowledge.  Is it possible you
> describe something which is not the problem I described?

I think that the above explanation applies to the example that you
provided here. There may well be a different explanation for what
happens with your real configuration.

dme.
-- 
I had my eyes closed in the dark.

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

* Re: [BUG] notmuch-emacs: spoils sendmail -f with emacs 27 commit 3a59cc84069376802ba8fd731b524d78db58262c and later
  2019-12-03 18:43 ` David Edmondson
  2019-12-03 19:15   ` Gregor Zattler
@ 2019-12-03 20:39   ` Stefan Monnier
  2019-12-03 22:22     ` David Edmondson
  1 sibling, 1 reply; 9+ messages in thread
From: Stefan Monnier @ 2019-12-03 20:39 UTC (permalink / raw)
  To: David Edmondson; +Cc: Gregor Zattler, notmuch

> disaster-area ~/s/emacs % ./src/emacs -Q -nw -batch --eval "(progn (require
> 'message) (setq mail-specify-envelope-from t mail-envelope-from 'header)
> (message \"%s\" message-sendmail-envelope-from))"
> nil
> disaster-area ~/s/emacs % 

Ha!  Thanks for tracking it down.

I installed the patch below into `master` to try and avoid this problem.


        Stefan


diff --git a/lisp/gnus/message.el b/lisp/gnus/message.el
index f33454e704..e60ea4f0e8 100644
--- a/lisp/gnus/message.el
+++ b/lisp/gnus/message.el
@@ -854,18 +854,24 @@ message-sendmail-f-is-evil
   :type 'boolean)
 
 (defcustom message-sendmail-envelope-from
-  ;; `mail-envelope-from' is unavailable unless sendmail.el is loaded.
-  (if (boundp 'mail-envelope-from) mail-envelope-from)
+  'obey-mail-envelope-from
   "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."
-  :version "23.2"
+  :version "27.1"
   :type '(choice (string :tag "From name")
 		 (const :tag "Use From: header from message" header)
+		 (const :tag "Obey `sendmail-envelope-from'"
+		        obey-mail-envelope-from)
 		 (const :tag "Use `user-mail-address'" nil))
   :link '(custom-manual "(message)Mail Variables")
   :group 'message-sending)
 
+(defun message--sendmail-envelope-from ()
+  (if (eq message-sendmail-envelope-from 'obey-mail-envelope-from)
+      (if (boundp 'mail-envelope-from) mail-envelope-from)
+    message-sendmail-envelope-from))
+
 (defcustom message-sendmail-extra-arguments nil
   "Additional arguments to `sendmail-program'."
   ;; E.g. '("-a" "account") for msmtp
@@ -5884,11 +5890,11 @@ message-user-mail-address
 
 (defun message-sendmail-envelope-from ()
   "Return the envelope from."
-  (cond ((eq message-sendmail-envelope-from 'header)
+  (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)
+	((stringp (message--sendmail-envelope-from))
+	 (message--sendmail-envelope-from))
 	(t
 	 (message-make-address))))
 
diff --git a/lisp/mail/emacsbug.el b/lisp/mail/emacsbug.el
index 1c2f11680b..fea7619b50 100644
--- a/lisp/mail/emacsbug.el
+++ b/lisp/mail/emacsbug.el
@@ -239,8 +239,8 @@ report-emacs-bug
       ;; Stop message-mode stealing the properties we will add.
       (set (make-local-variable 'message-strip-special-text-properties) nil)
       ;; Make sure we default to the From: address as envelope when sending
-      ;; through sendmail.
-      (when (and (not message-sendmail-envelope-from)
+      ;; through sendmail.  FIXME: Why?
+      (when (and (not (message--sendmail-envelope-from))
 		 (message-bogus-recipient-p (message-make-address)))
 	(set (make-local-variable 'message-sendmail-envelope-from) 'header)))
     (rfc822-goto-eoh)

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

* Re: [BUG] notmuch-emacs: spoils sendmail -f with emacs 27 commit 3a59cc84069376802ba8fd731b524d78db58262c and later
  2019-12-03 20:39   ` Stefan Monnier
@ 2019-12-03 22:22     ` David Edmondson
  2019-12-03 23:10       ` Stefan Monnier
  0 siblings, 1 reply; 9+ messages in thread
From: David Edmondson @ 2019-12-03 22:22 UTC (permalink / raw)
  To: Stefan Monnier; +Cc: Gregor Zattler, notmuch

On Tuesday, 2019-12-03 at 15:39:47 -05, Stefan Monnier wrote:

>> disaster-area ~/s/emacs % ./src/emacs -Q -nw -batch --eval "(progn (require
>> 'message) (setq mail-specify-envelope-from t mail-envelope-from 'header)
>> (message \"%s\" message-sendmail-envelope-from))"
>> nil
>> disaster-area ~/s/emacs % 
>
> Ha!  Thanks for tracking it down.
>
> I installed the patch below into `master` to try and avoid this problem.
>
>
>         Stefan
>
>
> diff --git a/lisp/gnus/message.el b/lisp/gnus/message.el
> index f33454e704..e60ea4f0e8 100644
> --- a/lisp/gnus/message.el
> +++ b/lisp/gnus/message.el
> @@ -854,18 +854,24 @@ message-sendmail-f-is-evil
>    :type 'boolean)
>  
>  (defcustom message-sendmail-envelope-from
> -  ;; `mail-envelope-from' is unavailable unless sendmail.el is loaded.
> -  (if (boundp 'mail-envelope-from) mail-envelope-from)
> +  'obey-mail-envelope-from
>    "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."
> -  :version "23.2"
> +  :version "27.1"
>    :type '(choice (string :tag "From name")
>  		 (const :tag "Use From: header from message" header)
> +		 (const :tag "Obey `sendmail-envelope-from'"

`sendmail-envelope-from' here should be `mail-envelope-from'.

> +		        obey-mail-envelope-from)
>  		 (const :tag "Use `user-mail-address'" nil))
>    :link '(custom-manual "(message)Mail Variables")
>    :group 'message-sending)
>  
> +(defun message--sendmail-envelope-from ()
> +  (if (eq message-sendmail-envelope-from 'obey-mail-envelope-from)
> +      (if (boundp 'mail-envelope-from) mail-envelope-from)
> +    message-sendmail-envelope-from))
> +
>  (defcustom message-sendmail-extra-arguments nil
>    "Additional arguments to `sendmail-program'."
>    ;; E.g. '("-a" "account") for msmtp
> @@ -5884,11 +5890,11 @@ message-user-mail-address
>  
>  (defun message-sendmail-envelope-from ()
>    "Return the envelope from."
> -  (cond ((eq message-sendmail-envelope-from 'header)
> +  (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)
> +	((stringp (message--sendmail-envelope-from))
> +	 (message--sendmail-envelope-from))
>  	(t
>  	 (message-make-address))))
>  
> diff --git a/lisp/mail/emacsbug.el b/lisp/mail/emacsbug.el
> index 1c2f11680b..fea7619b50 100644
> --- a/lisp/mail/emacsbug.el
> +++ b/lisp/mail/emacsbug.el
> @@ -239,8 +239,8 @@ report-emacs-bug
>        ;; Stop message-mode stealing the properties we will add.
>        (set (make-local-variable 'message-strip-special-text-properties) nil)
>        ;; Make sure we default to the From: address as envelope when sending
> -      ;; through sendmail.
> -      (when (and (not message-sendmail-envelope-from)
> +      ;; through sendmail.  FIXME: Why?
> +      (when (and (not (message--sendmail-envelope-from))
>  		 (message-bogus-recipient-p (message-make-address)))
>  	(set (make-local-variable 'message-sendmail-envelope-from) 'header)))
>      (rfc822-goto-eoh)

dme.
-- 
But are you safe Miss Gradenko?

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

* Re: [BUG] notmuch-emacs: spoils sendmail -f with emacs 27 commit 3a59cc84069376802ba8fd731b524d78db58262c and later
  2019-12-03 22:22     ` David Edmondson
@ 2019-12-03 23:10       ` Stefan Monnier
  2019-12-04 18:13         ` Gregor Zattler
  0 siblings, 1 reply; 9+ messages in thread
From: Stefan Monnier @ 2019-12-03 23:10 UTC (permalink / raw)
  To: David Edmondson; +Cc: Gregor Zattler, notmuch

>> +		 (const :tag "Obey `sendmail-envelope-from'"
> `sendmail-envelope-from' here should be `mail-envelope-from'.

Duh!  Thanks,


        Stefan

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

* Re: [BUG] notmuch-emacs: spoils sendmail -f with emacs 27 commit 3a59cc84069376802ba8fd731b524d78db58262c and later
  2019-12-03 19:15   ` Gregor Zattler
  2019-12-03 19:42     ` David Edmondson
@ 2019-12-04 12:03     ` David Edmondson
  1 sibling, 0 replies; 9+ messages in thread
From: David Edmondson @ 2019-12-04 12:03 UTC (permalink / raw)
  To: Gregor Zattler, notmuch; +Cc: Stefan Monnier

Gregor, does Stefan's change fix your problem?

dme.
-- 
So tap at my window, maybe I might let you in.

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

* Re: [BUG] notmuch-emacs: spoils sendmail -f with emacs 27 commit 3a59cc84069376802ba8fd731b524d78db58262c and later
  2019-12-03 23:10       ` Stefan Monnier
@ 2019-12-04 18:13         ` Gregor Zattler
  0 siblings, 0 replies; 9+ messages in thread
From: Gregor Zattler @ 2019-12-04 18:13 UTC (permalink / raw)
  To: Stefan Monnier, David Edmondson; +Cc: notmuch

Hi Stefan, David,
* Stefan Monnier <monnier@iro.umontreal.ca> [2019-12-03; 18:10]:
>>> +		 (const :tag "Obey `sendmail-envelope-from'"
>> `sendmail-envelope-from' here should be `mail-envelope-from'.
>
> Duh!  Thanks,

works with my configuration if this email hits the notmuch
mailing list.

Thanks for this patch, Gregor
--
 -... --- .-. . -.. ..--.. ...-.-

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

end of thread, other threads:[~2019-12-04 18:13 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-12-01 17:10 [BUG] notmuch-emacs: spoils sendmail -f with emacs 27 commit 3a59cc84069376802ba8fd731b524d78db58262c and later Gregor Zattler
2019-12-03 18:43 ` David Edmondson
2019-12-03 19:15   ` Gregor Zattler
2019-12-03 19:42     ` David Edmondson
2019-12-04 12:03     ` David Edmondson
2019-12-03 20:39   ` Stefan Monnier
2019-12-03 22:22     ` David Edmondson
2019-12-03 23:10       ` Stefan Monnier
2019-12-04 18:13         ` Gregor Zattler

Code repositories for project(s) associated with this public inbox

	https://yhetil.org/notmuch.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).