Today's Question:  What does your personal desk look like?        GIVE A SHOUT

Using msmtp to replace sendmail

  sonic0002        2012-09-27 11:41:48       13,494        0    

sendmail is a mail client in Linux with many vulnerabilities and tedius configuration steps, many system administrators have disabled using it. Then how do we know what happens if a crontab script executes with error?

Actually there are some replacements for sendmail, one is ssmtp, but this application is no longer maintained, we even cannot find its source code on Google. Fortunately, we can use msmtp to replace sendmail. The address : http://msmtp.sourceforge.net/

1. Installation

After downloading and decompressedm we run

./configure --prefix=/usr --libdir=/usr/lib64 --sysconfdir=/etc

make

make install

2. Configuration

If you add --sysconfdir=/etc in step 1, then the global configuration file is under /etc, with name msmtprc.

Here are some configurations

$ cat /etc/msmtprc 
defaults 
tls off 
logfile /var/log/msmtp.log

account default 
host mail.tudou.com 
from xxxx@tudou.com 
domain tudou.com 
auth login 
user sunchangming 
password xxxx

3. Let mail command call msmtp instead of sendmail

This is really simple, add one line in /etc/mail.rc

set sendmail="/usr/bin/msmtp"

4. Let crontab use msmtp

Open /etc/sysconfig/crond, set value of CRONDARGS

CRONDARGS="-m '/usr/bin/msmtp -t'"

Remember to add -t, otherwise msmtp will read recipients list from command line arg instead of stdin. If not adding the -t, you may get the following error

Sep 24 18:06:01 a02 crond[8023]: (app_admin) MAIL (mailed 52 bytes of output but got status 0x0040 )

Hope this will help someone.

Source : https://www.sunchangming.com/blog/?p=4358

SENDMAIL  MSMTP  REPLACEMENT 

Share on Facebook  Share on Twitter  Share on Weibo  Share on Reddit 

  RELATED


  0 COMMENT


No comment for this article.