Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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=<USER@TARGETHOST.TLD>, size=191, nrcpt=1 (queue active)
Nov  2 09:26:12 S01 postfix/local[12734]: 532301C318: to=<FORWARD_TO@TARGETHOST.TLD>, orig_to=<USER@TARGETHOST.TLD>, 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?

share|improve this question
    
What happens when you try to send email with just msmtpd? It should work; if it doesn't its an issue with msmtpd. –  josten Nov 1 '13 at 23:29
    
@josten, please take a look at the EDIT I've made. 10x a lot. –  Glister Nov 2 '13 at 10:07
    
You don't need the symlinks if you install msmtp-mta instead. –  colan Dec 6 '13 at 15:32
add comment

1 Answer

The solution was to add to the cron configuration for my user (by invoking crontab -e) this:

CRONARGS=-m/usr/bin/msmtp
share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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