Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Email reports bouncing back from external email servers when using sendmail #289

Open
Babber opened this issue Feb 12, 2021 · 2 comments
Open

Comments

@Babber
Copy link

Babber commented Feb 12, 2021

The address set by the Unattended-Upgrade::Sender parameter and then extracted by the -t switch of sendmail as defined in _send_mail_using_sendmail() sets the 'From' field in the email header indeed, but this appears to be not enough (or really almost all the same) regarding the successful delivery of my emails to my external email service provider. I always get the error status=bounced ... Sender address rejected: need fully-qualified address (in reply to RCPT TO command)).

The -r sender argument of sendmail however sets the 'Return-Path' and the 'smtp.mailfrom' fields, which in my case are the important ones. So that my emails get delivered at all, I had to change line #1398 in def _send_mail_using_sendmail() in unattended-upgrade from [SENDMAIL_BINARY, "-oi", "-t"], to [SENDMAIL_BINARY, "-oi", "-t", "-r "+from_address],. This might not be optimal as a general solution for everyone, this might break things in some other setups, I don't know about that. However, in my (I would say fairly common) case, this is the only way that sending emails to an external email service provider works at all.

As for the 'From' field, I am not sure what role it really plays other than appearing at the top of the email at the receiving side. Since it can really be anything (without a space and ideally in the format of an email address), I just replaced the line msg['From'] = from_address with msg['From'] = "unattended_upgrades@host.cc" where host is my machine's name and cc can be some country code. Without @host.cc, the email also gets delivered with @host added automatically to it, however if it always lends in your spam folder, give it the above format of a proper email address and add it to your contacts to white-list it.

A generally satisfying solution might have two distinct parameters in the config file corresponding to the above mentioned two parameters instead of having only the Unattended-Upgrade::Sender parameter controlling only the 'From' field, and not setting the parameters at all that are currently accessible only through the -r sender switch of sendmail.

@jacob-pro
Copy link

Yep the current behaviour is very confusing because despite being called Sender in the case of sendmail as you noted it only sets the From field.

It is also confusing that the default config suggests that mailx will be used, when actually sendmail is tried first:

A package that provides 'mailx' must be installed. E.g. "user@example.com"

This is particularly confusing if you are using nullmailer, which has the allmailfrom option which also works the wrong way around. It actually sets the Sender and does not modify the From field: bruceg/nullmailer#72

Therefore at present in order to use unattended-upgrades and nullmailer together you must set both

  • Unattended-Upgrade::Sender in order to set the From field
  • Nullmailer's allmailfrom to set the Sender

I think your idea of having two distinct parameters is great and will help make this less confusing

@Babber
Copy link
Author

Babber commented Jul 20, 2022

Thank you for the positive answer, @jacob-pro. I am looking forward to this enhancement.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants