Install a simple SMTP client:
sudo apt install msmtp  msmtp-mda
Set in msmtprc ::
cat   .msmtprc
account default
host smtp.qq.com
from [email protected]
auth on
tls on
tls_certcheck off
user [email protected]
password  xxxx
logfile ~/.msmtp.log
I can send email with qq account.
echo "Testing msmtp " | mail -s "hi root" -r [email protected]   -- [email protected]
The email can be found in yahoo email.
I find a new issue that user can't send email to root in system!
echo "cron task work done " | mail -s "hi root" root
mail: cannot send message: Process exited with a non-zero status
Check the log:
Aug 24 20:47:31 host=smtp.qq.com tls=on auth=on [email protected] [email protected] [email protected] smtpstatus=501 smtpmsg='501 Mail from address must be same as authorization user.' errormsg='envelope from address [email protected] not accepted by the server' exitcode=EX_DATAERR
echo "cron task work done " | mail -s "hi root" -r [email protected]  root
The log info:
Aug 29 06:56:39 host=smtp.qq.com tls=on auth=on [email protected] [email protected] [email protected] smtpstatus=501 smtpmsg='501 Mail from address must be same as authorization user.' errormsg='envelope from address [email protected] not accepted by the server' exitcode=EX_DATAERR
Everytime mail command was called ,it relay to external host smtp.qq.com enven if i specify return host as [email protected],how can make mail command send email between user and root in the system? I find that postfix or exim4 will be removed when to install msmtp-mda,the fact maybe realted with my issue.
