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!

1
  • 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. Jun 30, 2022 at 13:07

1 Answer 1

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.

1

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.