不可或缺的 sendEmail

时间:2021-09-10 03:45:07

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

  1. 一、sendEmail介绍
  2. SendEmail is a lightweight, command line SMTP email client. If you have the need to send email from a command line, this
  3. free program is perfect: simple to use and feature rich. It was designed to be used in bash scripts, batch files, Perl
  4. programs and web sites, but is quite adaptable and will likely meet your requirements. SendEmail is written in Perl and is
  5. unique in that it requires NO MODULES. It has an intuitive and flexible set of command-line options, making it very easy to
  6. learn and use.
  7. SendEmail is licensed under the GNU GPL, either version 2 of the License or (at your option) any later version.
  8. [Supported Platforms: Linux, BSD, OS X, Windows 98, Windows NT, Windows 2000, & Windows XP]
  9. 总的来说sendEmail简单,轻量级,命令行,可伸缩,跨平台。
  10. 二、下载与安装
  11. 下面的地址是sendEmail的下载及详细说明
  12. http://caspian.dotconf.net/menu/Software/SendEmail/
  13. 下面是安装描述,总共四个步骤就搞定。
  14. ------------------
  15. Installation
  16. ------------------
  17. SendEmail is a perl script/program, and only needs to be copied to a directory
  18. in your path to make it accessible.  Most likely the following steps will
  19. be sufficient:
  20. 1) Extract the package
  21. tar -zxvf sendEmail-v1.XX.tar.gz
  22. 2) Copy the sendEmail script to /usr/local/bin
  23. cp -a sendEmail-v1.XX/sendEmail /usr/local/bin
  24. 3) Make sure its executable
  25. chmod +x /usr/local/bin/sendEmail
  26. 4) Run it
  27. sendEmail
  28. or
  29. /usr/local/bin/sendEmail
  30. 三、用法
  31. 直接输入sendEmail,将出现该工具的用法介绍,如下所示。由于用法也简单明了,因此不一一解释
  32. robin@SZDB:~/dba_scripts/sendEmail-v1.56> ./sendEmail
  33. sendEmail-1.56 by Brandon Zehm <caspian@dotconf.net>
  34. Synopsis:  sendEmail -f ADDRESS [options]
  35. Required:
  36. -f ADDRESS                from (sender) email address
  37. * At least one recipient required via -t, -cc, or -bcc
  38. * Message body required via -m, STDIN, or -o message-file=FILE
  39. Common:
  40. -t ADDRESS [ADDR ...]     to email address(es)
  41. -u SUBJECT                message subject
  42. -m MESSAGE                message body
  43. -s SERVER[:PORT]          smtp mail relay, default is localhost:25
  44. Optional:
  45. -a   FILE [FILE ...]      file attachment(s)
  46. -cc  ADDRESS [ADDR ...]   cc  email address(es)
  47. -bcc ADDRESS [ADDR ...]   bcc email address(es)
  48. -xu  USERNAME             username for SMTP authentication
  49. -xp  PASSWORD             password for SMTP authentication
  50. Paranormal:
  51. -b BINDADDR[:PORT]        local host bind address
  52. -l LOGFILE                log to the specified file
  53. -v                        verbosity, use multiple times for greater effect
  54. -q                        be quiet (i.e. no STDOUT output)
  55. -o NAME=VALUE             advanced options, for details try: --help misc
  56. -o message-content-type=<auto|text|html>
  57. -o message-file=FILE         -o message-format=raw
  58. -o message-header=HEADER     -o message-charset=CHARSET
  59. -o reply-to=ADDRESS          -o timeout=SECONDS
  60. -o username=USERNAME         -o password=PASSWORD
  61. -o tls=<auto|yes|no>         -o fqdn=FQDN
  62. Help:
  63. --help                    the helpful overview you're reading now
  64. --help addressing         explain addressing and related options
  65. --help message            explain message body input and related options
  66. --help networking         explain -s, -b, etc
  67. --help output             explain logging and other output options
  68. --help misc               explain -o options, TLS, SMTP auth, and more
  69. 查看详细的帮助文件,如下方式:
  70. ./sendEmail --help addressing
  71. ./sendEmail --help message
  72. 四、示例
  73. #发送者使用任意的邮箱方式发送邮件
  74. robin@SZDB:~> sendEmail -f robinson@oracle.com \
  75. > -t robinson.cheng@trade.com \
  76. > -u "Test Mail" \
  77. > -m "This is a test mail from Robinson"
  78. Dec 18 14:10:23 szdb sendEmail[18494]: Email was sent successfully!
  79. #发送者使用一个真实存在的互联网邮件服务器来发送邮件
  80. robin@SZDB:~> sendEmail -f rocket010824@163.com \
  81. > -t robinson.cheng@trade.com \
  82. > -u "Test Mail" \
  83. > -s smtp.163.com \
  84. > -xu jackson \
  85. > -xp temp_000 \
  86. > -m "This is test mail from Robinson"
  87. Dec 18 14:13:24 szdb sendEmail[18500]: Email was sent successfully!
  88. 发送给多个邮件接收人
  89. robin@SZDB:~> sendEmail -f robinson@oracle.com \
  90. > -t "Robinson cheng <robinson.cheng@trade.com>" jackson@163.com \
  91. > -u "Send email to mutiple people" \
  92. > -m "This is a test mail"
  93. Dec 18 14:24:57 szdb sendEmail[18537]: Email was sent successfully!
  94. 使用抄送,密送接收人
  95. robin@SZDB:~> sendEmail -f robinson@oracle.com \
  96. > -t "Robinson cheng <robinson.cheng@trade.com>" \
  97. > -cc jason.wu@trade.com \
  98. > -bcc jackson@163.com \
  99. > -u "Test mail " \
  100. > -m "This is a test mail"
  101. 发送带有附件的邮件
  102. robin@SZDB:~> sendEmail -f robinson@oracle.com \
  103. > -t "Robinson cheng <robinson.cheng@trade.com>" \
  104. > -cc jason.wu@trade.com \
  105. > -u "Test mail with multi attached" \
  106. > -m "This is a test mail with multi attached" \
  107. > -a /users/robin/addmrpt_1_11584_11649.txt "/users/robin/Temp log"
  108. Dec 18 14:43:35 szdb sendEmail[18664]: Email was sent successfully!
  109. #使用文件内容作为邮件的body
  110. robin@SZDB:~> sendEmail -f robinson@oracle.com \
  111. > -t "Robinson cheng <robinson.cheng@trade.com>" \
  112. > -u "Test mail and the body from file contents" \
  113. > -o message-file=/users/robin/addmrpt_1_11584_11649.txt
  114. Dec 18 14:50:39 szdb sendEmail[18715]: Email was sent successfully!
  115. robin@SZDB:~> cat addmrpt_1_11584_11649.txt | sendEmail -f robinson@oracle.com \
  116. > -t "Robinson cheng <robinson.cheng@trade.com>" \
  117. > -u "Test mail and the body from file contents"
  118. Reading message body from STDIN because the '-m' option was not used.
  119. If you are manually typing in a message:
  120. - First line must be received within 60 seconds.
  121. - End manual input with a CTRL-D on its own line.
  122. Dec 18 14:47:31 szdb sendEmail[18709]: Message input complete.
  123. Dec 18 14:47:31 szdb sendEmail[18709]: Email was sent successfully!
  124. #发送邮件时读取html文件内容作为body
  125. robin@SZDB:~> sendEmail -f robinson@oracle.com \
  126. > -t "Robinson cheng <robinson.cheng@trade.com>" \
  127. > -u "HTML test mail" \
  128. > -o message-file=/users/robin/CNMMBO_awrrpt_1_20121218.html
  129. Dec 18 14:54:07 szdb sendEmail[18721]: Email was sent successfully!
  130. #Author :Robinson
  131. #Blog   : http://blog.csdn.net/robinson_0612
  132. #发送html邮件
  133. robin@SZDB:~> sendEmail -f robinson@oracle.com \
  134. > -t robinson.cheng@trade.com \
  135. > -u "This is an html test mail" \
  136. > -o message-content-type=html \
  137. > -m "The body is html format"
  138. Dec 18 15:19:36 szdb sendEmail[18883]: Email was sent successfully!
  139. 转:http://blog.csdn.net/leshami/article/details/8314570