Crontab failed to use msmtp to send mail

I want to use msmtp instead of postfix to send mail when crontab gets some errors, but I failed.

My OS is ubuntu 12.04

Here are my steps:

apt-get install msmtp-mta  #This will auto install msmtp, and symlink /usr/sbin/sendmail
apt-get install mailutils

Then I edit the file /etc/msmtprcin config smtp server:

defaults
tls off

account default
host smtp.ym.163.com
auth login
from myuser@mydomain.com
user myuser@mydomain.com
password mypss
logfile /var/log/msmtp.log
aliases /etc/aliases

Then I checked msmtp and it is OK

msmtp -Sd

loaded system configuration file /etc/msmtprc
ignoring user configuration file /root/.msmtprc: no such file or directory
falling back to default account
using account default from /etc/msmtprc
host                  = smtp.ym.163.com
port                  = 25
timeout               = off
protocol              = smtp
domain                = localhost
auth                  = LOGIN
user                  = myuser@mydomain
password              = *
passwordeval          = (not set)
ntlmdomain            = (not set)
tls                   = off
tls_starttls          = on
tls_trust_file        = (not set)
tls_crl_file          = (not set)
tls_fingerprint       = (not set)
tls_key_file          = (not set)
tls_cert_file         = (not set)
tls_certcheck         = on
tls_force_sslv3       = off
tls_min_dh_prime_bits = (not set)
tls_priorities        = (not set)
<-- 220 m199-177.yeah.net ESMTP HMail (1.0)
--> EHLO localhost
<-- 250-m199-177.yeah.net
<-- 250-PIPELINING
<-- 250-SIZE 71680000
<-- 250-ETRN
<-- 250-STARTTLS
<-- 250-AUTH LOGIN PLAIN
<-- 250-AUTH=LOGIN PLAIN
<-- 250-ENHANCEDSTATUSCODES
<-- 250 8BITMIME
--> QUIT
<-- 221 2.0.0 Bye
SMTP server at smtp.ym.163.com (m199-177.yeah.net [123.58.177.199]), port 25:
    m199-177.yeah.net ESMTP HMail (1.0)
Capabilities:
    SIZE 71680000:
        Maximum message size is 71680000 bytes = 68.36 MiB
    PIPELINING:
        Support for command grouping for faster transmission
    ETRN:
        Support for RMQS (Remote Message Queue Starting)
    STARTTLS:
        Support for TLS encryption via the STARTTLS command
    AUTH:
        Supported authentication methods:
        PLAIN LOGIN 
This server might advertise more or other capabilities when TLS is active.

Next step modified /etc/aliases

# See man 5 aliases for format
postmaster:    root
root: myuser@mydomain.com
default: myuser@mydomain.com

And I can use msmtp to send my email.

But in /var/log/cron.loghe got an error:

(root) MAIL (mailed 1 byte of output; but got status 0x004e, #012)

What happened? How to solve the problem? Can anyone give me a hand?

+3
source share
2 answers

Finally, I solved the problem myself ...

MAILTO=myemail /etc/crontab, , crontab -e. , var MAILTO . root not myemail, , msmtp .

/etc/aliases default: myemail, , .

, , utf-8, . ? ?

+1

, , . , , cron sendmail, $HOME /, /home/<user>. , msmtp sendmail , , $HOME/.msmtprc.

My SOLUTION /etc/msmtprc $HOME/.msmtprc.

, /etc/msmtprc .

: http://comments.gmane.org/gmane.linux.debian.devel.bugs.general/671011

+1

All Articles