0

I've got a Debian 11 system running as a local file server. I want to keep it as simple as possible but have some basic monitoring from Monit. I've installed and configured msmtp and msmtp-mta and I've confirmed that I can send test messages from the command line with

mail -s "test" address@email.com <<END
This is a test
END

and I've got emails coming through from unattended-upgrades.

I've seen guides where SMTP details are entered in the Monit config files, but I would prefer to only have the details stored in one place (/etc/msmtprc), so in my monit config file I've put set mailserver localhost. Monit is trying and failing to connect - in /var/log/monit.log I see:

[2023-04-25T16:43:24+0100] error    : Cannot connect to [localhost]:25 -- Connection refused
[2023-04-25T16:43:24+0100] error    : Cannot open a connection to the mailserver localhost:25 -- Operation now in progress
[2023-04-25T16:43:24+0100] error    : Mail: Delivery failed -- no mail server is available

Have I misunderstood something?

Vilas
  • 71
  • 1
  • 4
  • 1
    It appears the MTA daemon component of msmtp is not running (yet). A succesful mail command is not a test to check the daemon (`mail` makes use of the `/usr/lib/sendmail` function rather than connecting to port 25) https://marlam.de/msmtp/msmtp.html#Minimal-SMTP-server-_0028msmtpd_0029 – HBruijn Apr 28 '23 at 14:14

1 Answers1

0

Thanks @HBruijn, I thought it was something like that - the daemon was installed but not running.

I found a guide on how to set this up manually, but then I realised that the Debian package comes with an msmtpd.service file already (which was disabled), so I simply needed to run systemctl enable msmtpd.service and systemctl start msmtpd.service.

I then hit a permissions issue, which is described here - I ran chgrp msmtp /etc/msmtprc and chmod g+r /etc/msmtprc to allow the process to read the config file, and now it's working.

Vilas
  • 71
  • 1
  • 4