msmtp 是一款专门负责邮件发送的客户端软件,基于GPL发布,支持TLS/SSL、DNS模式、IPv6、服务器端认证、多用户等特性。
安装相关库
apt-get install msmtp
apt-get install gnutls-bin
apt-get install ca-certificates
配置
编辑~/.msmtprc
defaults
tls on
tls_starttls on
tls_trust_file /etc/ssl/certs/ca-certificates.crt
account default
host smtp.gmail.com
port 587
auth on
user yourmail@gmail.com
password yourpassword
from yourmail@gmail.com
logfile ~/.msmtp.log
创建log文件
touch ~/.msmtp.log
测试
msmtp testmail@qq.com < test.file
附,如果发送失败那多半是证书问题,把gmail安全保护关闭,进入下面这两个网站设置:
You need to allow less secure apps, you can do it by click
below link
https://www.google.com/settings/security/lesssecureapps
also try this one
https://accounts.google.com/DisplayUnlockCaptcha
if still not works try changing password for gmail