GNU bug report logs - #29427
Problem sending emails in message-mode after restart

Previous Next

Package: emacs;

Reported by: Emmanuel Boudreault <emmanuel.boudreault <at> polymtl.ca>

Date: Fri, 24 Nov 2017 17:35:02 UTC

Severity: normal

Tags: wontfix

Done: Lars Ingebrigtsen <larsi <at> gnus.org>

Bug is archived. No further changes may be made.

To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 29427 in the body.
You can then email your comments to 29427 AT debbugs.gnu.org in the normal way.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to bug-gnu-emacs <at> gnu.org:
bug#29427; Package emacs. (Fri, 24 Nov 2017 17:35:02 GMT) Full text and rfc822 format available.

Acknowledgement sent to Emmanuel Boudreault <emmanuel.boudreault <at> polymtl.ca>:
New bug report received and forwarded. Copy sent to bug-gnu-emacs <at> gnu.org. (Fri, 24 Nov 2017 17:35:02 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Emmanuel Boudreault <emmanuel.boudreault <at> polymtl.ca>
To: bug-gnu-emacs <at> gnu.org
Subject: Problem sending emails in message-mode after restart
Date: Fri, 24 Nov 2017 17:09:10 +0100
Hello,

I seem to be having an odd bug sending e-mails. I've configured msmtp to
send e-mails. When I first send an e-mail in emacs, 'send-mail-function'
isn't defined, I get a prompt, I choose transport and everything works
as expected. The msmtp log shows that the from field is properly set to
'emmanuel.boudreault <at> polymtl.ca'. This keeps working until emacs is
restarted.

When I restart emacs, 'send-mail-function' is defined. When I try to
send an e-mail, it fails saying the From field is incorrect. When I look
at the From field in the msmtp log it shows that emacs generated a From
field even though there was a valid one in the e-mail header. The From
field is: 'manu <at> soma.i-did-not-set--mail-host-address--so-tickle-me'.
The 'send-mail-function' is set to '(quote sendmail-send-it)'.

I'm using emacs 25.3, using notmuch-message-mode. I've looked into the
elisp and it seems that the problem arises in the emacs message mode
(message.el) used by notmuch-mesage-mode. Any help would be appreciated.


Thanks for you time,
Emmanuel




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#29427; Package emacs. (Fri, 24 Nov 2017 18:35:01 GMT) Full text and rfc822 format available.

Message #8 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Eric Abrahamsen <eric <at> ericabrahamsen.net>
To: bug-gnu-emacs <at> gnu.org
Subject: Re: bug#29427: Problem sending emails in message-mode after restart
Date: Fri, 24 Nov 2017 10:33:39 -0800
Emmanuel Boudreault <emmanuel.boudreault <at> polymtl.ca> writes:

> Hello,
>
> I seem to be having an odd bug sending e-mails. I've configured msmtp to
> send e-mails. When I first send an e-mail in emacs, 'send-mail-function'
> isn't defined, I get a prompt, I choose transport and everything works
> as expected. The msmtp log shows that the from field is properly set to
> 'emmanuel.boudreault <at> polymtl.ca'. This keeps working until emacs is
> restarted.
>
> When I restart emacs, 'send-mail-function' is defined. When I try to
> send an e-mail, it fails saying the From field is incorrect. When I look
> at the From field in the msmtp log it shows that emacs generated a From
> field even though there was a valid one in the e-mail header. The From
> field is: 'manu <at> soma.i-did-not-set--mail-host-address--so-tickle-me'.
> The 'send-mail-function' is set to '(quote sendmail-send-it)'.

This happens when the variable `user-mail-address' is not set (or
`message-user-fqdn', or `mail-host-address'). I assume you have one of
those variables set in one of your init files, and that init file is not
automatically loaded.

I'm not sure how `send-mail-function' comes into it, and am a bit
confused by your report: you say when you first send an email in emacs,
it isn't set, but later say when you restart emacs, it is defined.

Anyway, if you're using something based on message-mode, you should
probably just set `message-send-mail-function' directly.

HTH,
Eric





Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#29427; Package emacs. (Sat, 25 Nov 2017 17:21:01 GMT) Full text and rfc822 format available.

Message #11 received at 29427 <at> debbugs.gnu.org (full text, mbox):

From: "Basil L. Contovounesios" <contovob <at> tcd.ie>
To: Emmanuel Boudreault <emmanuel.boudreault <at> polymtl.ca>,
 Eric Abrahamsen <eric <at> ericabrahamsen.net>
Cc: 29427 <at> debbugs.gnu.org
Subject: Re: bug#29427: Problem sending emails in message-mode after restart
Date: Sat, 25 Nov 2017 17:19:57 +0000
Eric Abrahamsen <eric <at> ericabrahamsen.net> writes:

> Emmanuel Boudreault <emmanuel.boudreault <at> polymtl.ca> writes:
>
>> When I first send an e-mail in emacs, 'send-mail-function'
>> isn't defined [...]
>
> I'm not sure how `send-mail-function' comes into it, and am a bit
> confused by your report: you say when you first send an email in emacs,
> it isn't set, but later say when you restart emacs, it is defined.

Actually Emmanuel is saying the opposite, namely that
`send-mail-function' is somehow undefined until restarting
Emacs.  My issue with this is that `send-mail-function'
should always be defined as either `sendmail-send-it' or
`sendmail-query-once' when starting Emacs with the -Q flag,
in all versions of Emacs until at least as far back as 23.
Perhaps some custom configuration code or package is
misbehaving?

> Anyway, if you're using something based on message-mode, you should
> probably just set `message-send-mail-function' directly.

+1

-- 
Basil




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#29427; Package emacs. (Sun, 26 Nov 2017 15:23:02 GMT) Full text and rfc822 format available.

Message #14 received at 29427 <at> debbugs.gnu.org (full text, mbox):

From: "Basil L. Contovounesios" <contovob <at> tcd.ie>
To: Emmanuel Boudreault <emmanuel.boudreault <at> polymtl.ca>,
 Eric Abrahamsen <eric <at> ericabrahamsen.net>
Cc: 29427 <at> debbugs.gnu.org
Subject: Re: bug#29427: Problem sending emails in message-mode after restart
Date: Sun, 26 Nov 2017 15:21:47 +0000
[Message part 1 (text/plain, inline)]
Emmanuel - I am forwarding your email, which follows my
signature, to the bug report's address.  Unless sending a
private message, in the future please include
<29427 <at> debbugs.gnu.org> as a recipient.

Eric - I lack experience in mailing list etiquette, so if
forwarding wasn't the best mechanism for me to use here
please let me know what to do in the future.

Thanks,

-- 
Basil


[Message part 2 (message/rfc822, inline)]
From: Emmanuel Boudreault <emmanuel.boudreault <at> polymtl.ca>
To: "Basil L. Contovounesios" <contovob <at> tcd.ie>
Subject: Re: bug#29427: Problem sending emails in message-mode after restart
Date: Sun, 26 Nov 2017 08:20:40 +0100
>>> When I first send an e-mail in emacs, 'send-mail-function'
>>> isn't defined [...]
>>
>> I'm not sure how `send-mail-function' comes into it, and am a bit
>> confused by your report: you say when you first send an email in emacs,
>> it isn't set, but later say when you restart emacs, it is defined.

Once I send an e-mail from 'sendmail-query-once', 'send-mail-function'
is set to 'sendmail-send-it' in my config file by the
'sendmail-query-once' process. Things then work until I restart emacs.
After restarting emacs, message-mode tries to incorrectly guess the
'From' field of my e-mail even though it is already present.

> Actually Emmanuel is saying the opposite, namely that
> `send-mail-function' is somehow undefined until restarting
> Emacs.  My issue with this is that `send-mail-function'
> should always be defined as either `sendmail-send-it' or
> `sendmail-query-once' when starting Emacs with the -Q flag,
> in all versions of Emacs until at least as far back as 23.
> Perhaps some custom configuration code or package is
> misbehaving?

I'm sorry, I misspoke, I meant that I'm not defining
'send-mail-function' in my config file. I just checked and it is indeed
set to 'sendmail-query-once' when not set in my config file.

>> Anyway, if you're using something based on message-mode, you should
>> probably just set `message-send-mail-function' directly.
>
> +1

So this is my problem, when 'send-mail-function' is set to
'sendmail-send-it' or when 'message-send-mail-function' is set to
'message-send-mail-with-sendmail', somewhere in the message mode, the
code tries to guess my From and sets it incorrectly event though there
is already a valid from in the message.

To get things to work, I have to remove those settings set by
'sendmail-query-once' from my config file and restart emacs. Things then
work for that session.

Sorry for my bad initial explanation.


Thanks,
Emmanuel

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#29427; Package emacs. (Sun, 26 Nov 2017 19:34:02 GMT) Full text and rfc822 format available.

Message #17 received at 29427 <at> debbugs.gnu.org (full text, mbox):

From: Emmanuel Boudreault <emmanuel.boudreault <at> polymtl.ca>
To: "Basil L. Contovounesios" <contovob <at> tcd.ie>,
 Eric Abrahamsen <eric <at> ericabrahamsen.net>
Cc: 29427 <at> debbugs.gnu.org
Subject: Re: bug#29427: Problem sending emails in message-mode after restart
Date: Sun, 26 Nov 2017 20:33:51 +0100
> After restarting emacs, message-mode tries to incorrectly guess the
> 'From' field of my e-mail even though it is already present.

I have found a workaround. When emacs calls sendmail, it passes along a
'-f' argument with a badly formed from address and that is my problem.
The from address is obtained using the 'message-sendmail-envelope-from'
function in 'message.el'..

I found a nice comment:

```
;; Always specify who from,
;; since some systems have broken sendmails.
;; But some systems are more broken with -f, so
;; we'll let users override this.
(and (null message-sendmail-f-is-evil)
  (list "-f" (message-sendmail-envelope-from)))
```

By setting 'message-sendmail-f-is-evil', I can bypass this bit of code
and everything works as expected. However, this is just a workaround
and doesn't correct the fact that emacs is reading the From field
incorrectly.

> Emmanuel - I am forwarding your email, which follows my
> signature, to the bug report's address.

Thank you, I forgot to hit reply all.


Cheers,
Emmanuel




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#29427; Package emacs. (Mon, 27 Nov 2017 01:39:01 GMT) Full text and rfc822 format available.

Message #20 received at 29427 <at> debbugs.gnu.org (full text, mbox):

From: Glenn Morris <rgm <at> gnu.org>
To: Emmanuel Boudreault <emmanuel.boudreault <at> polymtl.ca>
Cc: "Basil L. Contovounesios" <contovob <at> tcd.ie>,
 Eric Abrahamsen <eric <at> ericabrahamsen.net>, 29427 <at> debbugs.gnu.org
Subject: Re: bug#29427: Problem sending emails in message-mode after restart
Date: Sun, 26 Nov 2017 20:37:58 -0500
Emmanuel Boudreault wrote:

> By setting 'message-sendmail-f-is-evil', I can bypass this bit of code
> and everything works as expected. However, this is just a workaround
> and doesn't correct the fact that emacs is reading the From field
> incorrectly.

So basically your issue is that your envelope-from isn't being set
correctly, because your system doesn't have a configured mail-host-address.

(setq message-sendmail-envelope-from 'header)

would presumably fix your problem as well, and might be a more sensible
default these days.

Related observations:

sendmail-send-it (which is what you selected by choosing "transport")
doesn't pass -f to sendmail by default. However, message.el uses its own
message-send-mail-with-sendmail instead, and this does pass -f by
default. This seems like a confusing difference, as well as a confusing
duplication of code (but that's message.el for you).

I would guess that you got sendmail-send-it the first time, then
message-send-mail-with-sendmail on all future invocations, owing to how
the variable message-send-mail-function gets initialized.

It all seems Very Complicated.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#29427; Package emacs. (Mon, 27 Nov 2017 23:11:01 GMT) Full text and rfc822 format available.

Message #23 received at 29427 <at> debbugs.gnu.org (full text, mbox):

From: Eric Abrahamsen <eric <at> ericabrahamsen.net>
To: Glenn Morris <rgm <at> gnu.org>
Cc: "Basil L. Contovounesios" <contovob <at> tcd.ie>, 29427 <at> debbugs.gnu.org,
 Emmanuel Boudreault <emmanuel.boudreault <at> polymtl.ca>
Subject: Re: bug#29427: Problem sending emails in message-mode after restart
Date: Mon, 27 Nov 2017 15:08:45 -0800
On 11/26/17 20:37 PM, Glenn Morris wrote:
> Emmanuel Boudreault wrote:
>
>> By setting 'message-sendmail-f-is-evil', I can bypass this bit of code
>> and everything works as expected. However, this is just a workaround
>> and doesn't correct the fact that emacs is reading the From field
>> incorrectly.
>
> So basically your issue is that your envelope-from isn't being set
> correctly, because your system doesn't have a configured mail-host-address.

I still think the simplest solution would be to set `user-mail-address'.
It's a reasonable thing to have set globally, and once it's set
everything else can be ignored.

> (setq message-sendmail-envelope-from 'header)
>
> would presumably fix your problem as well, and might be a more sensible
> default these days.
>
> Related observations:
>
> sendmail-send-it (which is what you selected by choosing "transport")
> doesn't pass -f to sendmail by default. However, message.el uses its own
> message-send-mail-with-sendmail instead, and this does pass -f by
> default. This seems like a confusing difference, as well as a confusing
> duplication of code (but that's message.el for you).
>
> I would guess that you got sendmail-send-it the first time, then
> message-send-mail-with-sendmail on all future invocations, owing to how
> the variable message-send-mail-function gets initialized.
>
> It all seems Very Complicated.

That's an understatement...




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#29427; Package emacs. (Mon, 13 May 2019 21:12:03 GMT) Full text and rfc822 format available.

Message #26 received at 29427 <at> debbugs.gnu.org (full text, mbox):

From: Lars Ingebrigtsen <larsi <at> gnus.org>
To: Glenn Morris <rgm <at> gnu.org>
Cc: "Basil L. Contovounesios" <contovob <at> tcd.ie>,
 Eric Abrahamsen <eric <at> ericabrahamsen.net>, 29427 <at> debbugs.gnu.org,
 Emmanuel Boudreault <emmanuel.boudreault <at> polymtl.ca>
Subject: Re: bug#29427: Problem sending emails in message-mode after restart
Date: Mon, 13 May 2019 17:11:10 -0400
Glenn Morris <rgm <at> gnu.org> writes:

> So basically your issue is that your envelope-from isn't being set
> correctly, because your system doesn't have a configured mail-host-address.
>
> (setq message-sendmail-envelope-from 'header)
>
> would presumably fix your problem as well, and might be a more sensible
> default these days.

I think so to, but I wouldn't be surprised if that breaks mail sending
on some systems.

> It all seems Very Complicated.

Mail is a mystery.

-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#29427; Package emacs. (Sun, 22 Sep 2019 23:15:01 GMT) Full text and rfc822 format available.

Message #29 received at 29427 <at> debbugs.gnu.org (full text, mbox):

From: Lars Ingebrigtsen <larsi <at> gnus.org>
To: Eric Abrahamsen <eric <at> ericabrahamsen.net>
Cc: "Basil L. Contovounesios" <contovob <at> tcd.ie>, Glenn Morris <rgm <at> gnu.org>,
 29427 <at> debbugs.gnu.org, Emmanuel Boudreault <emmanuel.boudreault <at> polymtl.ca>
Subject: Re: bug#29427: Problem sending emails in message-mode after restart
Date: Mon, 23 Sep 2019 01:13:50 +0200
Eric Abrahamsen <eric <at> ericabrahamsen.net> writes:

> I still think the simplest solution would be to set `user-mail-address'.
> It's a reasonable thing to have set globally, and once it's set
> everything else can be ignored.

Yes, I don't think there's anything to be done here to fix this in
general -- there's too many moving parts here to get things working on
all clients.  (And especially with a local MTA.)  So I'm closing this as
a "wontfix".

-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no




Added tag(s) wontfix. Request was from Lars Ingebrigtsen <larsi <at> gnus.org> to control <at> debbugs.gnu.org. (Sun, 22 Sep 2019 23:15:02 GMT) Full text and rfc822 format available.

bug closed, send any further explanations to 29427 <at> debbugs.gnu.org and Emmanuel Boudreault <emmanuel.boudreault <at> polymtl.ca> Request was from Lars Ingebrigtsen <larsi <at> gnus.org> to control <at> debbugs.gnu.org. (Sun, 22 Sep 2019 23:15:02 GMT) Full text and rfc822 format available.

bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Mon, 21 Oct 2019 11:24:04 GMT) Full text and rfc822 format available.

This bug report was last modified 4 years and 182 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.