您的位置:首页 > 运维架构 > Shell

shell下发送邮件工具sendEmail的用法详解

2016-11-05 14:35 302 查看
一.前言:

今天来分享一个可以在linux命令行(shell)模式下使用的发送电子邮件的软件sendEmail

首先上下载地址:http://caspian.dotconf.net/menu/Software/SendEmail/

安装方式简单,不需要编译,只需把可执行文件添加到环境变量$PATH目录直接使用即可,由于该软件使用Perl开发,所以需要安装Perl,使用该工具可便于对各种系统环境下定时运行的监控类脚本作出定时的反馈,并发送消息到管理员邮箱上。下面直接搬运Readme文件里的安装与使用方法,以及翻译和注释。

----------------------------------------------------------分隔线--------------------------------------------------------------

二.安装:

Installation

------------------

SendEmail is a perl script/program, and only needs to be copied to a directory

in your path to make it accessible.  Most likely the following steps will

be sufficient:

1) Extract the package

    tar -zxvf sendEmail-v1.XX.tar.gz        //解开压缩包

2) Copy the sendEmail script to /usr/local/bin

    cp -a sendEmail-v1.XX/sendEmail /usr/local/bin   //拷贝可执行脚本到环境变量目录下/usr/local/bin

3) Make sure its executable

    chmod +x /usr/local/bin/sendEmail     //把脚本添加可执行权限

4) Run it

    sendEmail

      or

    /usr/local/bin/sendEmail                //直接运行

NOTES:

  * Running sendEmail without any arguments will produce a usage summary.

  * SendEmail is written in Perl, so no compilation is needed.

  * On a Unix/Linux OS if your perl binary is not installed at /usr/bin/perl

    you may need to edit the first line of the script accordingly.

//不加任何参数使用sendEmail命令会出现使用方法提示

//SendEmail使用Perl语言编写,直接使用即可,不需要编译

//假如Perl没有安装在/usr/bin/perl下的时候需要修改脚本sendEmail的第一行定义相关Perl路径

三.使用方法:

Synopsis:  sendEmail -f ADDRESS [options]

  Required:

    -f ADDRESS                from (sender) email address              //发送人地址,除此之外至少使用一个-t或者-cc或者-bcc,邮件消息主体必须至少使用一个-m,或者标准输入读取,或者-o message-file

    * 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         //所使用发送邮件服务器(SMTP)

  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=<auto|text|html|other>            //指定正文文本格式,auto,text,html等等

        -o message-file=FILE               -o message-format=raw              //message-file指定邮件正文从文件读取,message-format指定消息正文格

        -o message-header=HEADER     -o message-charset=CHARSET           //message-header指定正文头部,message-charset指定正文字符集

        -o reply-to=ADDRESS          -o timeout=SECONDS                        //reply-to回复给指定地址,timeout指定超时时间

        -o username=USERNAME         -o password=PASSWORD          //username指定用户名,password指定密码

        -o tls=<auto|yes|no>         -o fqdn=FQDN                        //tls指定安全传输层协议(透明局域网服务?未验证)启用与否      fqdn意思是邮件地址显示全域名(Fully Qualified Domain
Name)

  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        //列出杂项类帮助

--------------------------------------------------------分隔线-----------------------------------------------------------------

四.例子:

sendEmail -f tom@mailserver.com -t tom@mailserver.com -s mail.mailserver.com -xu tom@mailserver.com -xp password -u "message subject" -m "message body"

//从发件人tom@mailserver.com发送给收件人tom@mailserver.com,通过的发件服务器为mail.mailserver.com,认证邮箱账号为tom@mail.server.com,账号密码为password,邮件主题为message subject,邮件正文为message body
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: