不可或缺的 sendEmail

    还在为Linux下没有便捷的邮件程序苦恼,还在为复杂的邮件服务器架设Google N多网页? 对于小型,便捷的Linux下命令行邮件程序,sendEmail使得这一切变得轻松可行。一起来看看吧。

一、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] 

  总的来说sendEmail简单,轻量级,命令行,可伸缩,跨平台。

二、下载与安装
  下面的地址是sendEmail的下载及详细说明
  http://caspian.dotconf.net/menu/Software/SendEmail/

  下面是安装描述,总共四个步骤就搞定。
  ------------------
  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
  
  3) Make sure its executable
      chmod +x /usr/local/bin/sendEmail
  
  4) Run it
      sendEmail
        or
      /usr/local/bin/sendEmail

三、用法    
  直接输入sendEmail,将出现该工具的用法介绍,如下所示。由于用法也简单明了,因此不一一解释
  robin@SZDB:~/dba_scripts/sendEmail-v1.56> ./sendEmail
  
  sendEmail-1.56 by Brandon Zehm <caspian@dotconf.net>
  
  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=<auto|text|html>
          -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=<auto|yes|no>         -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

  查看详细的帮助文件,如下方式: 
  ./sendEmail --help addressing
  ./sendEmail --help message

四、示例
  #发送者使用任意的邮箱方式发送邮件
  robin@SZDB:~> sendEmail -f robinson@oracle.com \
  > -t robinson.cheng@trade.com \
  > -u "Test Mail" \
  > -m "This is a test mail from Robinson"
  Dec 18 14:10:23 szdb sendEmail[18494]: Email was sent successfully!
  
  #发送者使用一个真实存在的互联网邮件服务器来发送邮件
  robin@SZDB:~> sendEmail -f rocket010824@163.com \
  > -t robinson.cheng@trade.com \
  > -u "Test Mail" \
  > -s smtp.163.com \
  > -xu jackson \
  > -xp temp_000 \
  > -m "This is test mail from Robinson"
  Dec 18 14:13:24 szdb sendEmail[18500]: Email was sent successfully!
  
  发送给多个邮件接收人
  robin@SZDB:~> sendEmail -f robinson@oracle.com \                                                                   
  > -t "Robinson cheng <robinson.cheng@trade.com>" jackson@163.com \
  > -u "Send email to mutiple people" \
  > -m "This is a test mail" 
  Dec 18 14:24:57 szdb sendEmail[18537]: Email was sent successfully!
  
  使用抄送,密送接收人
  robin@SZDB:~> sendEmail -f robinson@oracle.com \
  > -t "Robinson cheng <robinson.cheng@trade.com>" \
  > -cc jason.wu@trade.com \
  > -bcc jackson@163.com \
  > -u "Test mail " \
  > -m "This is a test mail"
  
  发送带有附件的邮件
  robin@SZDB:~> sendEmail -f robinson@oracle.com \
  > -t "Robinson cheng <robinson.cheng@trade.com>" \
  > -cc jason.wu@trade.com \
  > -u "Test mail with multi attached" \
  > -m "This is a test mail with multi attached" \
  > -a /users/robin/addmrpt_1_11584_11649.txt "/users/robin/Temp log"
  Dec 18 14:43:35 szdb sendEmail[18664]: Email was sent successfully!
  
  #使用文件内容作为邮件的body
  robin@SZDB:~> sendEmail -f robinson@oracle.com \
  > -t "Robinson cheng <robinson.cheng@trade.com>" \
  > -u "Test mail and the body from file contents" \
  > -o message-file=/users/robin/addmrpt_1_11584_11649.txt
  Dec 18 14:50:39 szdb sendEmail[18715]: Email was sent successfully!
  
  robin@SZDB:~> cat addmrpt_1_11584_11649.txt | sendEmail -f robinson@oracle.com \
  > -t "Robinson cheng <robinson.cheng@trade.com>" \
  > -u "Test mail and the body from file contents"
  Reading message body from STDIN because the '-m' option was not used.
  If you are manually typing in a message:
    - First line must be received within 60 seconds.
    - End manual input with a CTRL-D on its own line.
  
  Dec 18 14:47:31 szdb sendEmail[18709]: Message input complete.
  Dec 18 14:47:31 szdb sendEmail[18709]: Email was sent successfully!
  
  #发送邮件时读取html文件内容作为body
  robin@SZDB:~> sendEmail -f robinson@oracle.com \
  > -t "Robinson cheng <robinson.cheng@trade.com>" \
  > -u "HTML test mail" \
  > -o message-file=/users/robin/CNMMBO_awrrpt_1_20121218.html
  Dec 18 14:54:07 szdb sendEmail[18721]: Email was sent successfully!
  
  #Author :Robinson
  #Blog   : http://blog.csdn.net/robinson_0612
 
  #发送html邮件 
  robin@SZDB:~> sendEmail -f robinson@oracle.com \
  > -t robinson.cheng@trade.com \
  > -u "This is an html test mail" \
  > -o message-content-type=html \
  > -m "The body is html format"
  Dec 18 15:19:36 szdb sendEmail[18883]: Email was sent successfully! 

本文参与腾讯云自媒体分享计划,欢迎正在阅读的你也加入,一起分享。

发表于

我来说两句

0 条评论
登录 后参与评论

相关文章

来自专栏ASP.NET MVC5 后台权限管理系统

构建ASP.NET MVC4+EF5+EasyUI+Unity2.x注入的后台管理系统(8)-MVC与EasyUI DataGrid 分页

前言 为了符合后面更新后的重构系统,文章于2016-11-1日重写 EasyUI Datagrid在加载的时候会提交一些分页的信息到后台,我们需要根据这些信...

3587
来自专栏.NET开发那点事

.NET开源高性能Socket通信中间件Helios介绍及演示

  Helios是一套高性能的Socket通信中间件,使用C#编写。Helios的开发受到Netty的启发,使用非阻塞的事件驱动模型架构来实现高并发高吞吐量。H...

2302
来自专栏技术之路

lock小记

都快把lock忘了用wcf 给手持设备做服务的时候可能会有并发操作但又忘了lock的使用情况 做个小例子,怕自己再忘了 不加lock的时候 结果可能 是负的下面...

1956
来自专栏大内老A

谈谈WCF中的Data Contract(4):WCF Data Contract Versioning

软件工程是一门独特的工程艺术,需要解决的是不断改变的需求变化。而对于WCF,对于SOA,由于涉及的是对多个系统之间的交互问题,如何有效地解决不断改变的需求所带来...

2535
来自专栏函数式编程语言及工具

Akka(29): Http:Server-Side-Api,Low-Level-Api

 Akka-http针对Connection的两头都提供了方便编程的Api,分别是Server-Side-Api和Client-Side-Api。通过这两个Ap...

2178
来自专栏张善友的专栏

RESTful WCF

相较 WCF、WebService 使用 SOAP、WSDL、WS-* 而言,几乎所有的语言和网络平台都支持 HTTP 请求。我们无需去实现复杂的客户端代理,无...

19610
来自专栏Java成神之路

极光推送_总结_01_Java实现极光推送

1593
来自专栏王磊的博客

c# 检测cpu使用率[测试通过]

创建一个控制台应用程序,代码如下 using System; using System.Collections.Generic; using System.Li...

3514
来自专栏草根专栏

用VSCode开发一个asp.net core2.0+angular5项目(5): Angular5+asp.net core 2.0 web api文件上传

这部分就讲从angular5的客户端上传图片到asp.net core 2.0的 web api. 这是需要的源码: https://pan.baidu.com...

4135
来自专栏张善友的专栏

使用MongoDB的支持Linq 驱动NoRM

MongoDB的驱动有好几个,分布式文件存储的数据库开源项目MongoDB里使用的是github.com/samus/mongodb-csharp,monogo...

21910

扫码关注云+社区

领取腾讯云代金券