一、sendEmail介绍  

SendEmail is a lightweight, command line SMTP email client. If you have the need to send email from a command line, this

free program is perfect: simple to use and feature rich. It was designed to be used in bash scripts, batch files, Perl

programs and web sites, but is quite adaptable and will likely meet your requirements. SendEmail is written in Perl and is

unique in that it requires NO MODULES. It has an intuitive and flexible set of command-line options, making it very easy to

learn and use.

SendEmail is licensed under the GNU GPL, either version 2 of the License or (at your option) any later version.

[Supported Platforms: Linux, BSD, OS X, Windows 98, Windows NT, Windows 2000, & Windows XP]

sendmail是linux系统中一个邮箱系统,如果我们在系统中配置好sendmail就可以直接使用它来发送邮箱,sendEmail简单,轻量级,命令行,可伸缩,跨平台。 

二、sendEmail安装

  wget http://caspian.dotconf.net/menu/Software/SendEmail/sendEmail-v1.56.tar.gz
tar xvzf sendEmail-v1..tar.gz
cp sendEmail-v1./sendEmail /usr/local/bin/
chmod +x /usr/local/bin/sendEmail

三 sendEmail的使用

    这里通过编辑一个shell脚本来工zabbix监控程序来调用。

     cd /apps/svr/zabbix/share/zabbix /alertscripts
vim sendEmail.sh #!/bin/bash
SMTP_server='smtp.163.com'# SMTP服务器
username='zabbixxxxx@163.com' # 用户名
password='xxxxxxxxxx' # 密码
from_email_address='zabbixfish@163.com' # 发件人Email地址
to_email_address="$1" # 收件人Email地址,zabbix传入的第一个参数
message_subject_utf8="$2" # 邮件标题,zabbix传入的第二个参数
message_body_utf8="$3" # 邮件内容,zabbix传入的第三个参数 # 转换邮件标题为GB2312,解决邮件标题含有中文,收到邮件显示乱码的问题。
message_subject_gb2312=`iconv -t GB2312 -f UTF- << EOF
$message_subject_utf8
EOF`
[ $? -eq ] && message_subject="$message_subject_gb2312" || message_subject="$message_subject_utf8" # 转换邮件内容为GB2312
message_body_gb2312=`iconv -t GB2312 -f UTF- << EOF
$message_body_utf8
EOF`
[ $? -eq ] && message_body="$message_body_gb2312" || message_body="$message_body_utf8" # 发送邮件
sendEmail='/usr/local/bin/sendEmail'
$sendEmail -s "$SMTP_server" -xu "$username" -xp "$password" -f "$from_email_address" -t "$to_email_address" -u "$message_subject" -m "$message_body" -o message-content-type=text -o message-charset=gb2312 tls=no [root@localhost alertscripts]# chmod +x sendEmail.sh
[root@localhost alertscripts]# ./sendEmail.sh xxxxxx@qq.com zabbix hello
Jul :: localhost sendEmail[]: Email was sent successfully!

解释:

-f 表示发送者的邮箱
-t 表示接收者的邮箱
-s 表示SMTP服务器的域名或者ip
-u 表示邮件的主题
-xu 表示SMTP验证的用户名
-xp 表示SMTP验证的密码
-m 表示邮件的内容
-o  message-charset  邮件字符集

-o  message-content-type=text 表示邮件的内容格式为 text ,另外还有html格式

 故障以及解决方案

故障现象:

# sendEmail -f from@.com -t toi@qq.com -u "TestMail" -s smtp..com -xu cgh -xp passwd \
> -m "This is test mail "
*******************************************************************
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 .
invalid SSL_version specified at /usr/share/perl5/vendor_perl/IO/Socket/SSL.pm line

故障一解决方案:

 a、卸载现有的perl版本,安装老版本(不推荐)
b、增加参数-o tls=no 选项
# sendEmail -f from@.com -t to@qq.com -u "TestMail" -s smtp..com -xu cgh -xp passwd \
> -m "This is test mail from Robinson" -o tls=no
Sep :: hn249 sendEmail[]: Email was sent successfully!

故障二现象:

 # sendEmail -f chengguohua@htyjie.com -t leshami@qq.com -u "TestMail" -s smtp.exmail.qq.com -xu xxxxx -xp passwd \
> -m "This is test mail from xxxx" -o tls=no
Sep :: hn249 sendEmail[]: ERROR => ERROR => SMTP-AUTH: Authentication to smtp.exmail.qq.com: failed.

故障解决方案:

需要在163邮件设置一个客户端授权密码即可。

注:其实sendEmail是一个十分有用的程序,我们在这个地方用了它,其实别的地方也可以用,典型的好处就是你不需要每台机器都装sendmail,开启smtp服务.直接用现成的一台邮件服务器就行了,这无疑很大的加强了系统的安全性,也节约了资源.

sendMail在centos下的安装的更多相关文章

  1. centos下编译安装lnmp

    centos下编译安装lnmp 本文以centos为背景在其中编译安装nginx搭建lnmp环境. 编译安装nginx时,需要事先安装 开发包组"Development Tools" ...

  2. CentOS下一键安装Openstack

    CentOS下一键安装Openstack 系统环境:Oracle VirtualBox 4.38CentOS-6.5-x86_64-bin-DVD1.iso 安装前需要修改 /etc/hosts文件, ...

  3. mac和centos下git安装

    mac下面的git安装,这篇文章写的很详细了http://www.cnblogs.com/ccdev/archive/2012/09/12/2682098.html 谈谈centos下的安装.我用的是 ...

  4. centOS下yum安装配置samba

     centOS下yum安装配置samba 2010-03-29 15:46:00 标签:samba yum centOS 安装 休闲 注意:本文的原则是只将文件共享应用于内网服务器,并让将要被共享的目 ...

  5. centos下apache安装后无法访问

    2013.11.28遇到的问题: -------------------------------------- 一.centos下apache安装后无法访问 得查一下防火墙的问题 iptables添加 ...

  6. centos下yum安装crontab+mysql自动备份

    参考博文: centos下yum安装crontab yum install vixie-cron crontabs      //安装 chkconfig crond on               ...

  7. CentOS下Mysql安装教程

    CentOS下Mysql安装教程 本人学习Linux时使用的是CentOs5.5版本,在该环境中,Mysql的安装方法有很多种,下面我只讲我这次成功了的方法,作为一个记录,供大家参考,同时给自己做一个 ...

  8. CentOS下Docker安装

    CentOS下Docker安装 1.安装: #sudo yum install docker 2.启动并加入开机启动: A.#sudo systemctl start docker B.#sudo s ...

  9. (转载)Centos下Elasticsearch安装详细教程

    原文地址:http://www.cnblogs.com/sunny1009/articles/7874251.html Centos下Elasticsearch安装详细教程 1.Elasticsear ...

随机推荐

  1. linux使用virtualenv构建虚拟环境,requirement.txt记录包版本

    virtualenv介绍: virtualenv把是一个把python应用隔离在一个虚拟环境中的工具.网上的例子较多,这里重点讲述怎么使用virtualenv来激活一个虚拟环境,并且记录虚拟环境中所依 ...

  2. Flask的配置文件

    Flask的配置文件 与 session 配置文件 flask中的配置文件是一个flask.config.Config对象(继承字典) 默认配置为: { 'DEBUG': get_debug_flag ...

  3. TF随笔-4

    >>> import tensorflow as tf>>> a=tf.constant([[1,2],[3,4]])>>> b=tf.const ...

  4. Okhttp源码简单解析(一)

    业余时间把源码clone下来大致溜了一遍,并且也参阅了其余大神的博客,在这里把自己的心得记录下来共享之,如有不当的地方欢迎批评指正.本文是Okttp源码解析系列的第一篇,不会深入写太多的东西,本篇只是 ...

  5. [置顶] 个人博客上线!欢迎来访~ http://onlyloveyd.cn/

    简介 Hexo + Github + 个人域名 构建静态博客系统. 构建方法 参考 https://yq.aliyun.com/articles/64953 个人博客网站 Cherish Androi ...

  6. Debian, Ubuntu, LinuxMint 安裝 MySQL 5.7, 5.6, 5.5

    以下會示範在 Debian, Ubuntu 及 LinuxMint 分別安裝 MySQL 5.7, 5.6, 5.5 的方法. 首先按照需要的安裝的 MySQL 版本, 加入相應的 Repositor ...

  7. android wifi 热点、socket通讯

    WiFi管理工具类 package com.wyf.app.common; import java.lang.reflect.InvocationTargetException; import jav ...

  8. vector释放内存之swap方法

    相信大家看到swap这个词都一定不会感到陌生,就是简单的元素交换.但swap在C++ STL中散发着无穷的魅力.下面将详细的说明泛型算法swap和容器中的swap成员函数的使用! 1. 泛型算法swa ...

  9. RESTful 服务示例

    WCF服务轻量级服务,可供JS调用 返回值格式:XML.Json 工程结构: 示例代码: using System; using System.Collections.Generic; using S ...

  10. LG4779 【模板】单源最短路径(标准版)

    题意 给定一个 \(N\) 个点,\(M\) 条有向边的带非负权图,请你计算从 \(S\) 出发,到每个点的距离. 数据保证你能从 \(S\) 出发到任意点. \(1≤N≤100000\): \(1≤ ...