Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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?



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. – jersten 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

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

share|improve this answer
This worked for me on CentOS 7, but not on Debian unstable. I think it only works for some versions of the cron daemon, namely cronie. – jobo3208 Jan 14 at 15:47

I had exactly the same scenario as described in the question, however the current answer didn't fix the problem for me. In my case, the explanation of the problem was that every time when cron executed sendmail command it was setting $HOME to /, rather than /home/<user>. Thus even if msmtp replaced sendmail via a symlink it was not able to find its user-specific config file located in $HOME/.msmtprc.

My SOLUTION was to use /etc/msmtprc instead of $HOME/.msmtprc.

This may not be the best solution for your system, as it may force some sensitive data from your /etc/msmtprc to be readable by other users.

Read more here:

share|improve this answer

Your Answer


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.