LogWatch SMTP auth

logginglogwatchsmtp

So I've been using LogWatch for a little while and wanted to customize it a bit, so this is one of the things I want to edit.

I want LogWatch to verify via SMTP?

My mailserver (iREDmail) has some quite strict rules regarding auth, so that I have to set a password for an account and it has to be in the system.

How do I set up LogWatch to STMP auth with email and password?

Best Answer

Hi if you want logwatch send mail using smtp account you can use package msmtp (debian) and configure logwatch to use it, it send smtp authenticated mail as result. You dont need postfix, setting itself dont affect existing MTA configuration in system.

Step 1 : install and test msmtp

apt-get install msmtp

configure it by create config file in user home folder

cd ~
touch ./.msmtprc
edit .msmtprc

edit and paste this content to suite your needs

account default
host mail.domain.tld
port 587
from user@domain.tld
auth on
user user@domain.tld
password myverysecretpass
tls on
tls_certcheck off 

tls_certcheck off # if you dont want check ssl cert of mailserver

tls_trust_file mycacertificatefile # if you want check ca certificate

Save file and check/verify configuration using command

msmtp -S

Step 2 : edit configuration of logwatch

edit /etc/logwatch/conf/logwatch.conf

find existing mailer line and comment it. make new line and change target mail address

mailer = "/usr/bin/msmtp administrator@domain.tld"

Check that mail address in logwatch match mail in .msmtprc otherwise you will get Non Delivery Report back

MailFrom = user@domain.tld

save and run logwatch script, check email in target mailbox, if nothing comes check mailbox of user@domain.tld for Non Delivery Report for problems

This solution works for me, i get mail correct way and I using DMARC and DKIM correctly for reports i need.