系统:ubuntu
设置 SMTP 服务器,使用命令行发送邮件
安装 mailutils msmtp msmtp-mta bsd-mailx
1 | sudo apt install mailutils msmtp msmtp-mta bsd-mailx -y |
编写 MSMTP 配置文件 ~/.msmtprc
1 | sudo vim ~/.msmtprc |
配置下面选项
1 | # Set default values for all following accounts. |
测试发送邮件,使用 msmtp 或者 mail
1 | echo -e "Subject: Test\n\nThis is a test email with mail command" | msmtp [email protected] |
1 | echo "Testing mail from ${HOSTNAME} with mail command" | mail -s "Hello" [email protected] |
参考:
msmtp
Setting up email with SMTP on Ubuntu/Debian Servers