2

I have a CentOS 8-stream server. I was setting up smartmontools to monitor my drives. The MTA is msmtp. To test the setup, I modified my smartd.conf by adding:

/dev/sda -a -m my.mail@pro.vider -M test

Since I did not see any mail popping up, I decided to check the journal:

journalctl -u smartd

which gave the following:

smartd[1184]: Executing test of <mail> to my.mail@pro.vider...
smartd[1184]: Test of <mail> to my.mail@pro.vider produced unexpected output (459 bytes) to STDOUT/STDERR:
smartd[1184]: send-mail: cannot connect to smtp.gmail.com, port 587: Permission denied
smartd[1184]: send-mail: could not send mail (account default from /etc/msmtprc)
smartd[1184]: send-mail: cannot log to /var/log/msmtp.log: cannot open: Permission denied
smartd[1184]: send-mail: log info was: host=smtp.gmail.com tls=on auth=on user=my.mail@pro.vider from=my.mail@pro.vider recipients=my.mail@pro.vider errormsg='cannot connect to smtp.gmail.com, port 587: Permission denied' exitcode=EX_TEMPFAIL

So, I tried:

echo "My message" | mail -s "Some subject" my.mail@pro.vider

which does send the mail, but still shows the error:

 send-mail: cannot log to /var/log/msmtp.log: cannot open: Permission denied

I thought, it might be an issue with SE permissions, so I checked:

getsebool -a | grep mail

which gave:

gitosis_can_sendmail --> off
httpd_can_sendmail --> on
logging_syslogd_can_sendmail --> on
logwatch_can_network_connect_mail --> on
mailman_use_fusefs --> off
postfix_local_write_mail_spool --> on

I have two errors, but no idea how to rectify these. Would be glad if someone could point me in the right direction.

Thanks a bunch!

  • Chances are pretty high that it's a selinux issue. Set it to permissive mode and see if it helps. If yes, there are lots of tutorials on how to allow the disallowed operations. – Gerald Schneider Jun 30 '22 at 13:07

1 Answers1

0

send-mail: cannot connect to smtp.gmail.com, port 587: Permission denied send-mail: could not send mail (account default from /etc/msmtprc)

This is probably an authentication problem, check your credentials in your /etc/msmtprc.

send-mail: cannot log to /var/log/msmtp.log: cannot open: Permission denied

It could be AppArmor forbidding to log to /var/log/msmtp.log.

I don't know about CentOS, but you might want to take a look at this AskUbuntu question anyway. On Ubuntu there is a default AppArmor profile that only allows logging to /var/log/msmtp (without the .log extention).

Or you can try with syslog LOG_MAIL (which should log to /var/log/mail.log) instead of logfile /var/log/msmtp.log in your msmtprc, as suggested here.

Dario Seidl
  • 416
  • 5
  • 12