I'm trying to configure a machine so that it will send me an email if one of the cronjobs output something in case of an error.
I'm using Debian Wheezy.
Cron is working normally (without the email functionality).
msmtp is installed and configured. Have already symlinked /usr/{bin|sbin}/sendmail to /usr/bin/msmtp.
I can send email by using:
echo "test" | mail -s "subject" user@target.
tld
or by executing:
echo "test" | /usr/sbin/sendmail
Without the symlink (/usr/sbin/sendmail) cron will tell me that:
(CRON) info (No MTA installed, discarding output)
With the symlinks I get:
(root) MAIL (mailed 1 byte of output; but got status 0x004e, #012)
Can you suggest how to config the cron/msmtp pair?
Thanks!
EDIT:
Note: I've written "msmtpd" by mistake. Its not a daemon but rather an SMTP client named just "msmtp" (without the "d" ending). It is executed on demand and it is not running in the background all the time.
When I try to send an email by using msmtp like that it works:
echo "test" | msmtp USER@TARGETHOST.
TLD
On the far side, in the logs of the SMTP server I read:
Nov 2 09:26:10 S01 postfix/smtpd[12728]: connect from unknown[CLIENT_IP]
Nov 2 09:26:12 S01 postfix/smtpd[12728]: 532301C318: client=unknown[CLIENT_IP], sasl_method=CRAM-MD5, sasl_username=USER@TARGETHOST.
TLD
Nov 2 09:26:12 S01 postfix/cleanup[12733]: 532301C318: message-id=<>
Nov 2 09:26:12 S01 postfix/qmgr[2404]: 532301C318: from=<
[email protected]>, size=191, nrcpt=1 (queue active)
Nov 2 09:26:12 S01 postfix/local[12734]: 532301C318: to=<
[email protected]>, orig_to=<
[email protected]>, relay=local, delay=0.62, delays=0.59/0.01/0/0.03, dsn=2.0.0, status=sent (delivered to command: IFS=' ' && exec /usr/bin/procmail -f- || exit 75 #1001)
Nov 2 09:26:12 S01 postfix/qmgr[2404]: 532301C318: removed
Nov 2 09:26:13 S01 postfix/smtpd[12728]: disconnect from unknown[CLIENT_IP]
And the Email is delivered to the target user. So it looks like that the msmtp client is working properly.
It has to be something in the cron/msmtp integration, but I have no clue what that thing might be. Can you help me?