1.安装mailx msmtp
2.修改配置文件
新建~/.msmtprc
- host smtp.gmail.com
- domain gmail.com
- tls on
- tls_starttls on
- tls_certcheck off
- protocol smtp
- auth on
- user yourname@gmail.com
- password yourpassword
- from yourname@gmail.com
最好不要使用gmail,使用163的比较好
新建~/.mailrc
set sendmail="/usr/bin/msmtp"
echo 'test from msmtp' | mail -s 'hello' demo@163.com