sendEmail -- invalid SSL_version at SSL.pm

  sendEmail實現郵件發送,遭遇invalid SSL_version,同時對於使用騰訊的免費企業郵箱也有一些問題,下面是故障描述及解決方案。html

一、故障現象

[root@VM_106_88_centos ~]# sendEmail -f from@163.com -t to@qq.com -s smtp.163.com -u \
"i am the subject" -o message-content-type=html -o message-charset=utf8 \
-xu from@163.com -xp mypassword -m "i am the contenter"
*******************************************************************
 Using the default of SSL_verify_mode of SSL_VERIFY_NONE for client
 is deprecated! Please set SSL_verify_mode to SSL_VERIFY_PEER
 together with SSL_ca_file|SSL_ca_path for verification.
 If you really don't want to verify the certificate and keep the
 connection open to Man-In-The-Middle attacks please set
 SSL_verify_mode explicitly to SSL_VERIFY_NONE in your application.
*******************************************************************
  at /usr/local/bin/sendEmail line 1906.
invalid SSL_version specified at /usr/share/perl5/vendor_perl/IO/Socket/SSL.pm line 415.

二、環境

[root@VM_106_88_centos ~]# cat /etc/redhat-release 
CentOS Linux release 7.2.1511 (Core)

2、解決方案

一、SSL.pm文件415行

415     ${*$self}{'_SSL_ctx'} = IO::Socket::SSL::SSL_Context->new($arg_hash) || return;

# perl -v

This is perl 5, version 16, subversion 3 (v5.16.3) built for x86_64-linux-thread-multi
(with 29 registered patches, see perl -V for more detail)

因爲在CentOS 7下perl的版本爲5.16,而centos6.5的是5.10,版本不兼容

二、解決方案

a、卸載現有的perl版本,安裝老版本(不推薦)
b、增長參數-o tls=no 選項

[root@VM_106_88_centos ~]# sendEmail -f from@163.com -t to@qq.com -s smtp.163.com -u \
"i am the subject" -o message-content-type=html -o message-charset=utf8 \
-xu from@163.com -xp mypassword -m "i am the contenter" -o tls=no

Dec 27 16:16:34 localhost sendEmail[13958]: Email was sent successfully!

三、其餘問題(騰訊免費郵箱不支持傳統的smtp 25號端口方式

========================================================================================python

sendEmail的安裝及使用方法:linux

1.下載軟件centos

wget http://caspian.dotconf.net/menu/Software/SendEmail/sendEmail-v1.56.tar.gz

2.解壓軟件服務器

tar zxf sendEmail-v1.56.tar.gz -C /usr/src

3.進入目錄app

cd /usr/src/sendEmail-v1.56

4.複製文件,並設置權限ide

cp -a sendEmail /usr/local/bin
chmod +x /usr/local/bin/sendEmail

5.安裝組件測試

yum install perl-Net-SSLeay perl-IO-Socket-SSL -y

6.測試郵件功能ui

# /usr/local/bin/sendEmail -f from@163.com -t to@qq.com -s smtp.163.com -u "我是郵件主題" -o message-content-type=html -o message-charset=utf8 -xu from@163.com -xp 123456 -m "我是郵件內容"

命令說明:編碼

/usr/local/bin/sendEmail       命令主程序
-f from@163.com                發件人郵箱
-t to@163.com                  收件人郵箱
-s smtp.163.com                發件人郵箱的smtp服務器
-u "我是郵件主題"              郵件的標題
-o message-content-type=html   郵件內容的格式,html表示它是html格式
-o message-charset=utf8      郵件內容編碼
-xu from@163.com          發件人郵箱的用戶名
-xp 123456              發件人郵箱密碼
-m "我是郵件內容"          郵件的具體內容
相關文章
相關標籤/搜索