Ubuntu 16.04 TLS 配置 sendEmail 的报错问题

sendEmail 是一个很好用的发送邮件的

sendEmail 官方站点:http://caspian.dotconf.net/menu/Software/SendEmail/#installation

下载: sendEmail-v1.56.tar.gz (2009年更新的)

解压:

guli@guli-Ubuntu1:/root/sendEmail-v1.56$ ls
CHANGELOG README README-BR.txt sendEmail sendEmail.pl TODO

复制 sendEmail 到 /usr/local/bin 下即可在命令行使用。

sendEmail 是一个 perl 脚本:
$ file sendEmail
sendEmail: a /usr/bin/perl -w script, ASCII text executable

使用示例:

sendEmail -f [email protected] -t [email protected] -s smtp.163.com -u "邮件主题" -o message-content-type=html -o message-charset=utf8 -xu guli3057from -xp gulixxxx -m "邮件内容" -a $file

163 邮箱账户:[email protected]
密码:xxxx (登陆密码)

设置 -> POP3/SMTP/IMAP -> 设置POP3/SMTP/IMAP: -> 开启 POP3/SMTP服务和IMAP/SMTP服务
需要配置授权码:gulixxxx(sendEmail -xp 选项使用这个授权码)

在 Ubuntu 16.04 TLS 上使用会有错误:

$ ./sendEmail -f [email protected] -t [email protected] -s smtp.163.com -u "邮件主题" -o message-content-type=html -o message-charset=utf8 -xu guli3057from -xp gulixxxx -m "邮件内容"
invalid SSL_version specified at /usr/share/perl5/IO/Socket/SSL.pm line 575.

这表示不支持 SSL_version 版本,应该是软件太老了,而系统太新。

有两种方法修复问题:

1,不使用 TLS 加密

添加选项:-o tls=no

2,修改 sendEmail 脚本:

第 1906 行,将 'SSLv3 TLSv1' 修改为 'SSLv23:!SSLv2':

$ diff sendEmail sendEmail_

1906c1906
<         if (! IO::Socket::SSL->start_SSL($SERVER, SSL_version => 'SSLv3 TLSv1')) {
---
>         if (! IO::Socket::SSL->start_SSL($SERVER, SSL_version => 'SSLv23:!SSLv2')) {
```

参考:https://unix.stackexchange.com/questions/53065/invalid-ssl-version-specified-at-usr-share-perl5-io-socket-ssl-pm-line-332


另外,官网的还提供了一种方法,是安装低版本的 perl,感觉比较不方便,我也没实现,就不描述了。


修改之后发送成功:

    $ ./sendEmail_ -f [email protected] -t [email protected] -s smtp.163.com -u "邮件主题:当地在线数据" -o message-content-type=html -o message-charset=utf8 -xu guli3057from -xp guli12345 -m "邮件内容:当地在线数据"
    Apr 27 16:13:17 guli-ubuntu1 sendEmail_[2248]: Email was sent successfully!



sendEmail 的 help 信息:

    $ ./sendEmail

    sendEmail-1.56 by Brandon Zehm 

    Synopsis:  sendEmail -f ADDRESS [options]

      Required:
        -f ADDRESS                from (sender) email address
        * At least one recipient required via -t, -cc, or -bcc
        * Message body required via -m, STDIN, or -o message-file=FILE

      Common:
        -t ADDRESS [ADDR ...]     to email address(es)
        -u SUBJECT                message subject
        -m MESSAGE                message body
        -s SERVER[:PORT]          smtp mail relay, default is localhost:25

      Optional:
        -a   FILE [FILE ...]      file attachment(s)
        -cc  ADDRESS [ADDR ...]   cc  email address(es)
        -bcc ADDRESS [ADDR ...]   bcc email address(es)
        -xu  USERNAME             username for SMTP authentication
        -xp  PASSWORD             password for SMTP authentication

      Paranormal:
        -b BINDADDR[:PORT]        local host bind address
        -l LOGFILE                log to the specified file
        -v                        verbosity, use multiple times for greater effect
        -q                        be quiet (i.e. no STDOUT output)
        -o NAME=VALUE             advanced options, for details try: --help misc
            -o message-content-type=
            -o message-file=FILE         -o message-format=raw
            -o message-header=HEADER     -o message-charset=CHARSET
            -o reply-to=ADDRESS          -o timeout=SECONDS
            -o username=USERNAME         -o password=PASSWORD
            -o tls=         -o fqdn=FQDN

      Help:
        --help                    the helpful overview you're reading now
        --help addressing         explain addressing and related options
        --help message            explain message body input and related options
        --help networking         explain -s, -b, etc
        --help output             explain logging and other output options
        --help misc               explain -o options, TLS, SMTP auth, and more

你可能感兴趣的:(Ubuntu 16.04 TLS 配置 sendEmail 的报错问题)