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

$Conf{EMailFromUserName} is overridden by "auto_from on" in /etc/msmtprc #27

Open
toggoboge opened this issue Sep 1, 2019 · 5 comments

Comments

@toggoboge
Copy link

I am running the BackupPC v4.3.1 version of the container.

BTW, below I have obscured my domain as 'mydomain.com'.

$Conf{EMailFromUserName} is overridden by "auto_from on" in /etc/msmtprc, meaning the configured from-address is not used in outgoing emails.

Using SMTP_HOST & SMTP_MAIL_DOMAIN environment variables, I have configured the backuppc container to send emails via a local SMTP relay container (docker pull namshi/smtp).

I've created a Gmail account, mailrelay@mydomain.com, for use by the SMTP relay container. The Gmail account has also been setup with an alias, backuppc-server@mydomain.com, and emails sent by a small python script from this address via my local SMTP relay are successfully received as coming from backuppc-server@mydomain.com.

In the backuppc container, I have set $Conf{EMailFromUserName} to backuppc-server@mydomain.com.

When I try to send a test email to backuppc@mydomain.com from inside the container, I see the following:

bash-5.0$ /usr/local/BackupPC/bin/BackupPC_sendEmail -u backuppc@mydomain.com
Sending test email using /usr/sbin/sendmail -t -f backuppc-server@mydomain.com

This successfully sends emails via my local SMTP relay. However, the mails are always received as coming from mailrelay@mydomain.com.

In spite of backuppc-server@mydomain.com being used on the sendmail command-line, I see the following in the headers:

From: mailrelay@mydomain.com
X-Google-Original-From: backuppc@mydomain.com

Gmail is not honouring the from-address because mailrelay@mydomain.com has permission to send emails from backuppc-server@mydomain.com, but not from backuppc@mydomain.com.

I think this is happening because the "auto_from on" setting in /etc/msmtprc is causing msmtp to generate the from-address from the Linux username, 'backuppc' in this case. This causes the configured $Conf{EMailFromUserName} to be overridden, and backuppc@mydomain.com is used as the from-address instead of backuppc-server@mydomain.com.

Manually changing "auto_from on" to "auto_from off" in /etc/msmtprc has fixed this for me (at least for test emails - I haven't yet checked other emails auto-sent by BackupPC), and the test email sent by the BackupPC_sendEmail command above, is now received by backuppc@mydomain.com with the from-address is correctly set to backuppc-server@mydomain.com.

@toggoboge
Copy link
Author

Oh, if you do decide to update entrypoint.sh to address this, it'd be nice to have an environment variable that allows users to enable msmtp logging, perhaps defaulting the logfile to /home/backuppc/msmtp.log if no path is provided. As I was changing it by hand anyhow, I've also modified /etc/msmtprc to include this line:

logfile /home/backuppc/msmtp.log

@adferrand
Copy link
Owner

Hello @toggoboge! Just to let you know that I saw your issue and did not forgot it. I will handle it as soon as I have some time.

@toggoboge
Copy link
Author

Thanks. Maybe /var/log is a better location for a logfile.

@adferrand
Copy link
Owner

Hello @toggoboge, I finally got the time to handle this issue.

So, I improved the logic to fit the usecase you described here. Basically:

  • all logs from msmtp are now stored in /var/log/msmtp.log, and also in supervisord stdout. I hope this will help a lot to debug mail issues
  • also, when SMTP_MAIL_DOMAIN is empty (the default), msmtp does not try to rewrite the envelope-from in mails generated by backuppc. So $Conf{EMailFromUserName} will be used, not overwritten. If SMTP_MAIL_DOMAIN is set, the envelope-from will be overwritten to USER@SMTP_MAIL_DOMAIN, like before.

@toggoboge
Copy link
Author

toggoboge commented Mar 3, 2020 via email

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

No branches or pull requests

2 participants