Ubuntu: Logwatch email failing with “invalid sender domain”



Question:

I run logwatch manually (no cron job). I use nullmailer to send emails from the server using my ISP's SMTP server. I can send test emails from command line no problem. But logwatch is using a bad "From" address that causes my ISP to reject the email, and I can't find the setting to change.

In my logwatch config file I have MailFrom = me@gmail.com. The first lines of the email generated by logwatch look like this:

root@myserverhostname.gmail.com  me@timewarnercable.com    Received: (nullmailer pid 5939 invoked by uid 0);      Sun, 25 Sep 2016 15:25:02 -0000  To: me@timewarnercable.com  From: root@gmail.com  Subject: Logwatch for myserverhostname (Linux)  

Notice that the address in first line of the file has myserverhostname inserted into it. Unfortunately, this seems to be the address that is really used. The domain on the From: line is correct, and would work, except that it changed my username to root. The To: line and the 2nd line of the file match.

Note: the From: address is not exactly what is shown in the logwatch config file. I specified MailFrom = me@gmail.com and it shows up in the From as root@gmail.com. It appears that the config file settings for logwatch are being overridden somewhere.

How can I stop logwatch from inserting myserverhostname into the From address and changing my name to root?

Edit: relevant portion of logwatch.conf

# Default person to mail reports to.  Can be a local account or a  # complete email address.  Variable Output should be set to mail, or  # --output mail should be passed on command line to enable mail feature.  MailTo = me@timewarnercable.com  # WHen using option --multiemail, it is possible to specify a different  # email recipient per host processed.  For example, to send the report  # for hostname host1 to user@example.com, use:  #Mailto_host1 = user@example.com  # Multiple recipients can be specified by separating them with a space.    # Default person to mail reports from.  Can be a local account or a  # complete email address.  MailFrom = me@gmail.com  

The error from mail.log

Sep 25 11:15:52 myserverhostname nullmailer[10724]: smtp: Failed: 550 5.1.0 <root@myserverhostname.gmail.com> sender rejected : invalid sender domain  

Bottom line When logwatch generates the email, it is not using the value I supplied in the MailFrom line of the config file.

On MailFrom, I supplied me@gmail.com but it used root@myserverhostname.gmail.com in the first line of the email, and root@gmail.com in the From: line of the email. I need it to say me@gmail.com in the first line at least. If I manually edit the email and replace that line, it sends just fine.


Solution:1

Many thanks to heynnema for his helpful suggestions. He pointed me to the 2nd configuration file which could be modified to fix the problem.

This turned out not to be a problem with logwatch, or nullmailer, but with sendmail itself. It was sendmail that was ignoring the inputs from the logwatch config file and inserting its own value of the From address.

Fortunately, the /user/share/logwatch/dist.conf/logwatch.conf file has a line

mailer = "/usr/sbin/sendmail -t"  

I was able to force the correct From address by changing this to read

mailer = "/usr/sbin/sendmail -t -f me@gmail.com"  

Note:If u also have question or solution just comment us below or mail us on toontricks1994@gmail.com
Previous
Next Post »