在LEDE中通过SSMTP发送邮件

安装SSMTP

root@LEDE:~# opkg update
root@LEDE:~# opkg install ssmtp
Package ssmtp (2.64-5) installed in root is up to date.

配置SSMTP

/etc/ssmtp/ssmtp.conf

#
# /etc/ssmtp.conf -- a config file for sSMTP sendmail.
#

# The person who gets all mail for userids < 1000
# Make this empty to disable rewriting.
# 此处修改为邮件发送服务器的邮件账户
root=ted_sender@outlook.com

# The place where the mail goes. The actual machine name is required
# no MX records are consulted. Commonly mailhosts are named mail.domain.com
# The example will fit if you are in domain.com and your mailhub is so named.
# 此处修改为邮件发送服务器的smtp服务地址,不一定有端口号
mailhub=smtp-mail.outlook.com:587

# Example for SMTP port number 2525
# mailhub=mail.your.domain:2525
# Example for SMTP port number 25 (Standard/RFC)
# mailhub=mail.your.domain
# Example for SSL encrypted connection
# mailhub=mail.your.domain:465

# Where will the mail seem to come from?
# 此处修改为邮件发送服务器的主机
rewriteDomain=outlook.com

# The full hostname
# 此处修改为邮件发送服务器的主机
hostname=outlook.com

# Set this to never rewrite the "From:" line (unless not given) and to
# use that address in the "from line" of the envelope.
FromLineOverride=YES

# Use SSL/TLS to send secure messages to server.
#UseTLS=YES

# Use SSL/TLS certificate to authenticate against smtp host.
#UseTLSCert=YES

#针对outlook邮件服务器,需要添加此项
UseSTARTTLS=YES

# Use this RSA certificate.
#TLSCert=/etc/ssl/certs/ssmtp.pem

# Get enhanced (*really* enhanced) debugging information in the logs
# If you want to have debugging of the config file parsing, move this option
# to the top of the config file and uncomment
#Debug=YES
#发送邮件账户名称
AuthUser=ted_sender@outlook.com
#发送邮件账户密码
AuthPass=****

发送邮件

sendEmail.sh

#!/bin/sh
echo "From:<ted_sender@outlook.com>
To: xiong-wei@hotmail.com
Subject: From Ted Home LEDE

Something has gone wrong at service $1 , Please check soon!!!
" | ssmtp -f "tedxiong.com" -F "www.tedxiong.com" xiong-wei@hotmail.com

调用脚本发送邮件

root@LEDE:~# ./sendEmail TestEmail

其他

  • 使用A类邮件服务器发给B类邮件服务的邮件很容易被认定为垃圾邮件,比如用outlook的邮件服务给163的邮件发。但是给同类邮件服务器的邮箱发送就不会被拒收,所以我专门注册了一个邮箱作为发送邮箱,来给我的outlook邮箱发邮件。

本作品由TedXiong采用知识共享署名-非商业性使用-相同方式共享 4.0 国际许可协议进行许可。

Copyright © tedxiong.com 2017 all right reserved,powered by Gitbook该文章修改时间: 2018-03-02 17:59:48

results matching ""

    No results matching ""