(一)首先安装ssmpt和mailutils:
sudo apt-get install ssmtp mailutils
(二)接下来编辑配置文件sudo gedit /etc/ssmtp/ssmtp.conf
root=YOUR_PERSONAL_MAIL@DOMAIN
mailhub=smtp.gmail.com:465
rewriteDomain=gmail.com
AuthUser=YOUR_GMAIL_ACCOUNT
AuthPass=YOUR_GMAIL_PASSWORD
hostname=SERVER_HOST_NAME
FromLineOverride=YES
UseTLS=YES
(三)配置好之后,就可以进行邮件的发送,有很多种发送的方式:
1.echo "Hi, This is mail from test server" | mail -s "test mail from test server" MAIL_TO_SEND@DOMAIN
2.将邮件内容写到一个txt文件中,如body.txt
用mail命令发送,foyo23@zhuidaniu.com是收件人地址,
mail -s "这是邮件标题" foyo23@zhuidaniu.com < body.txt