unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* bug#29427: Problem sending emails in message-mode after restart
@ 2017-11-24 16:09 Emmanuel Boudreault
  2017-11-24 18:33 ` Eric Abrahamsen
  2017-11-26 15:21 ` Basil L. Contovounesios
  0 siblings, 2 replies; 9+ messages in thread
From: Emmanuel Boudreault @ 2017-11-24 16:09 UTC (permalink / raw)
  To: 29427

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@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@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





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

* bug#29427: Problem sending emails in message-mode after restart
  2017-11-24 16:09 bug#29427: Problem sending emails in message-mode after restart Emmanuel Boudreault
@ 2017-11-24 18:33 ` Eric Abrahamsen
  2017-11-25 17:19   ` Basil L. Contovounesios
  2017-11-26 15:21 ` Basil L. Contovounesios
  1 sibling, 1 reply; 9+ messages in thread
From: Eric Abrahamsen @ 2017-11-24 18:33 UTC (permalink / raw)
  To: 29427

Emmanuel Boudreault <emmanuel.boudreault@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@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@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






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

* bug#29427: Problem sending emails in message-mode after restart
  2017-11-24 18:33 ` Eric Abrahamsen
@ 2017-11-25 17:19   ` Basil L. Contovounesios
  0 siblings, 0 replies; 9+ messages in thread
From: Basil L. Contovounesios @ 2017-11-25 17:19 UTC (permalink / raw)
  To: Emmanuel Boudreault, Eric Abrahamsen; +Cc: 29427

Eric Abrahamsen <eric@ericabrahamsen.net> writes:

> Emmanuel Boudreault <emmanuel.boudreault@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





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

* bug#29427: Problem sending emails in message-mode after restart
  2017-11-24 16:09 bug#29427: Problem sending emails in message-mode after restart Emmanuel Boudreault
  2017-11-24 18:33 ` Eric Abrahamsen
@ 2017-11-26 15:21 ` Basil L. Contovounesios
  2017-11-26 19:33   ` Emmanuel Boudreault
  1 sibling, 1 reply; 9+ messages in thread
From: Basil L. Contovounesios @ 2017-11-26 15:21 UTC (permalink / raw)
  To: Emmanuel Boudreault, Eric Abrahamsen; +Cc: 29427

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

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@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



[-- Attachment #2: Type: message/rfc822, Size: 11636 bytes --]

From: Emmanuel Boudreault <emmanuel.boudreault@polymtl.ca>
To: "Basil L. Contovounesios" <contovob@tcd.ie>
Subject: Re: bug#29427: Problem sending emails in message-mode after restart
Date: Sun, 26 Nov 2017 08:20:40 +0100
Message-ID: <87d145ecaf.fsf@soma.i-did-not-set--mail-host-address--so-tickle-me>

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

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

* bug#29427: Problem sending emails in message-mode after restart
  2017-11-26 15:21 ` Basil L. Contovounesios
@ 2017-11-26 19:33   ` Emmanuel Boudreault
  2017-11-27  1:37     ` Glenn Morris
  0 siblings, 1 reply; 9+ messages in thread
From: Emmanuel Boudreault @ 2017-11-26 19:33 UTC (permalink / raw)
  To: Basil L. Contovounesios, Eric Abrahamsen; +Cc: 29427

> 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





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

* bug#29427: Problem sending emails in message-mode after restart
  2017-11-26 19:33   ` Emmanuel Boudreault
@ 2017-11-27  1:37     ` Glenn Morris
  2017-11-27 23:08       ` Eric Abrahamsen
  2019-05-13 21:11       ` Lars Ingebrigtsen
  0 siblings, 2 replies; 9+ messages in thread
From: Glenn Morris @ 2017-11-27  1:37 UTC (permalink / raw)
  To: Emmanuel Boudreault; +Cc: Basil L. Contovounesios, Eric Abrahamsen, 29427

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.





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

* bug#29427: Problem sending emails in message-mode after restart
  2017-11-27  1:37     ` Glenn Morris
@ 2017-11-27 23:08       ` Eric Abrahamsen
  2019-09-22 23:13         ` Lars Ingebrigtsen
  2019-05-13 21:11       ` Lars Ingebrigtsen
  1 sibling, 1 reply; 9+ messages in thread
From: Eric Abrahamsen @ 2017-11-27 23:08 UTC (permalink / raw)
  To: Glenn Morris; +Cc: Basil L. Contovounesios, 29427, Emmanuel Boudreault


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





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

* bug#29427: Problem sending emails in message-mode after restart
  2017-11-27  1:37     ` Glenn Morris
  2017-11-27 23:08       ` Eric Abrahamsen
@ 2019-05-13 21:11       ` Lars Ingebrigtsen
  1 sibling, 0 replies; 9+ messages in thread
From: Lars Ingebrigtsen @ 2019-05-13 21:11 UTC (permalink / raw)
  To: Glenn Morris
  Cc: Basil L. Contovounesios, Eric Abrahamsen, 29427,
	Emmanuel Boudreault

Glenn Morris <rgm@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





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

* bug#29427: Problem sending emails in message-mode after restart
  2017-11-27 23:08       ` Eric Abrahamsen
@ 2019-09-22 23:13         ` Lars Ingebrigtsen
  0 siblings, 0 replies; 9+ messages in thread
From: Lars Ingebrigtsen @ 2019-09-22 23:13 UTC (permalink / raw)
  To: Eric Abrahamsen; +Cc: Basil L. Contovounesios, 29427, Emmanuel Boudreault

Eric Abrahamsen <eric@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





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

end of thread, other threads:[~2019-09-22 23:13 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-11-24 16:09 bug#29427: Problem sending emails in message-mode after restart Emmanuel Boudreault
2017-11-24 18:33 ` Eric Abrahamsen
2017-11-25 17:19   ` Basil L. Contovounesios
2017-11-26 15:21 ` Basil L. Contovounesios
2017-11-26 19:33   ` Emmanuel Boudreault
2017-11-27  1:37     ` Glenn Morris
2017-11-27 23:08       ` Eric Abrahamsen
2019-09-22 23:13         ` Lars Ingebrigtsen
2019-05-13 21:11       ` Lars Ingebrigtsen

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

	https://git.savannah.gnu.org/cgit/emacs.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).