发送邮件

使用命令行发送邮件有很多方式,这里选用较为简单的 SSMTP 工具。


安装

sudo apt-get install ssmtp


配置

1. 先修改发送模块的配置

/etc/ssmtp/ssmtp.conf
#                                                                                                                 
# Config file for sSMTP sendmail
#
# The person who gets all mail for userids < 1000
# Make this empty to disable rewriting.
root=[your name]
 
# The place where the mail goes. The actual machine name is required no
# MX records are consulted. Commonly mailhosts are named mail.domain.com
mailhub=smtp.qq.com:465
 
# Where will the mail seem to come from?
#rewriteDomain=
 
# The full hostname
hostname=ubuntu
 
# Are users allowed to set their own From: address?
# YES - Allow the user to specify their own From: address
# NO - Use the system generated From: address
#FromLineOverride=YES
 
AuthUser=[your email address]
AuthPass=[your email password]
FromLineOverride=YES
UseTLS=YES

2. 然后编辑内容进行发送测试 文件名这里假定为 content.txt

To: jovi.meng@adleida.com                                                                                          
From: 601352745@qq.com
Subject: Saber here
 
sth happend clearly

3. 最后发送

ssmtp jovi.meng@adleida.com < content.txt

说明
gmail server 发邮件需要生成安全传输层协议所需的密文,这里暂时选用腾讯的邮件服务器演示,以后会追加。


FIXME

Jovi Meng 2017/09/08 08:35