1. 程式人生 > >shell下發送郵件工具sendEmail的用法詳解

shell下發送郵件工具sendEmail的用法詳解

一.前言:

今天來分享一個可以在linux命令列(shell)模式下使用的傳送電子郵件的軟體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 [email protected] -t [email protected] -s mail.mailserver.com -xu [email protected] -xp password -u "message subject" -m "message body"

//從發件人[email protected]傳送給收件人[email protected],通過的發件伺服器為mail.mailserver.com,認證郵箱賬號為[email protected],賬號密碼為password,郵件主題為message subject,郵件正文為message body

相關推薦

shell下發郵件工具sendEmail用法

一.前言: 今天來分享一個可以在linux命令列(shell)模式下使用的傳送電子郵件的軟體sendEmail 安裝方式簡單,不需要編譯,只需把可執行檔案新增到環境變數$PATH目錄直接使用即可,

shell命令行下發郵件

-a image 創建 smtp 完成 成了 我想 事先 鏈接 我的電腦用於學習linux,所以分區,格式化,重裝系統經常事。 很多時候,寫完筆記,並沒有對數據進行備份。因為我想我不會再重裝系統了,但這種想法經常被打破。 為了解決這個問師,我選擇用移動硬盤備份,但是文件太小

shell郵件函數

發送郵件函數#發送郵件函數function send_mail(){ #定義郵件發送列表 maillist=( zhengwei.liu@xxx xiaogang.yang@xxx sundy.she@xxx ) if [ "$1" == "gateway" ];the

JavaMail發郵件工具

連接 protoc soc 控制臺顯示 itl 郵件標題 new conn () SendMailUitls: package com.duocy.util; import java.net.InetAddress; import java.util.Properties;

Apache ab壓力測試工具Window下載和用法

ab是apache自帶的網站壓力測試工具。 使用起來非常的簡單和方便。 不僅僅是可以apache伺服器進行網站訪問壓力測試,還可以對其他型別的伺服器進行壓力測試。 比如nginx,tomcat,IIS等 首先當然是下載安裝了。 在這裡只講window下在下載安裝 官方下載地址:,(htt

linux下發郵件

先安裝一個mailx yum install mailx 配置: 126郵箱為例,自己去官網註冊一個,在這裡我註冊了一個[email protected] 在/etc/mail.rc檔案末尾加入如下配置 set [email protected] set s

flask框架下發郵件

各種郵箱的配置參考 百度經驗-如何檢視各種郵箱的服務SMTP/POP3地址及埠號 各種郵箱埠 163郵箱 QQ郵箱 程式碼 # -*- coding:utf-8 -*- from flask import Flask from flask_mail imp

【Apache】Apache ab壓力測試工具Window下載和用法

enc ons 所有 The 產生 ima 腳本 數據 等待 ab是apache自帶的網站壓力測試工具。 使用起來非常的簡單和方便。 不僅僅是可以apache服務器進行網站訪問壓力測試,還可以對其他類型的服務器進行壓力測試。 比如nginx,tomcat,IIS等 首先當然

python使用sendmail在linux下發郵件

使用linux下的sendmail程式來發送郵件,利用popen函式(python docs關於popen函式)可以直接呼叫linux系統程式,需要指定程式所在的位置。 #!/usr/bin/py

apache自帶的ab壓力測試工具用法

ab是apache自帶的一個很好用的壓力測試工具,當安裝完apache的時候,就可以在bin下面找到ab 1 我們可以模擬100個併發使用者,對一個頁面傳送1000個請求 ./ab -n1000 -c100 http://www.baidu.com 其中-n代表請求數,

工具】輕量級 linux 命令列發郵件工具--SendEmail

An Email Program for Sending SMTP Mail from a Command Line About SendEmail SendEmail is a lightweight, command line SMTP email clien

shell中的for迴圈用法

for 命令: for i in 的各種用法 : for i in “file1” “file2” “file3” for i in /boot/* for i in /etc/*.conf for i in $(seq -w 10)

使用blat在命令列下發郵件

Blat is a Windows (32 & 64 bit) command line utility that sends eMail using SMTP or post to usen

shell 中 if 和 else 用法

基本語法 shell的if語法和C語言等高階語言非常相似,唯一需要注意的地方就是shell的if語句對空格方面的要求比較嚴格(其實shell對所有語法的空格使用都比較嚴格),如果在需要空格的地方沒有打上空格,都會報錯。如if [ $1x == "ip"x ];then ec

linux伺服器下發郵件

    系統管理人員經常會遇到對於裝置或者任務的預警與通知,通常情況有傳送簡訊、郵件等方式。傳送簡訊一般來說需要有簡訊貓(硬體)或者呼叫libfetion給飛信使用者傳送。本文介紹幾種簡單的傳送郵件的方式。 本文環境:Ubuntu 10.04 基礎:       Linux

Linux(CentOS7)下發郵件(使用Gmail作為發件服務器)

發送郵件 lin src 圖片 div vim 導航 all mex 參考下述文章的思路,補充了在Gmail上的相關設置 https://gist.github.com/ilkereroglu/aa6c868153d1c5d57cd8 1。安裝mailx

JavaScript中return的用法

style 返回 www log tle blog 意思 charset fun 1、定義:return 從字面上的看就是返回,官方定義return語句將終止當前函數並返回當前函數的值,可以看下下面的示例代碼: <!DOCTYPE html><html l

SVN trunk(主線) branch(分支) tag(標記) 用法和詳細操作步驟

trac load mar span 必須 最可 objc copy 右鍵 原文地址:http://blog.csdn.net/vbirdbest/article/details/51122637 使用場景: 假如你的項目(這裏指的是手機客戶端項目)的某個版本(例如1.0

js 定時器用法——setTimeout()、setInterval()、clearTimeout()、clearInterval()

ntb 幫助 .get tint num 用法 -c 函數 tel 在js應用中,定時器的作用就是可以設定當到達一個時間來執行一個函數,或者每隔幾秒重復執行某段函數。這裏面涉及到了三個函數方法:setInterval()、setTimeout()、clearI

selenium用法

key url enc element api code 需要 int question selenium用法詳解 selenium主要是用來做自動化測試,支持多種瀏覽器,爬蟲中主要用來解決JavaScript渲染問題。 模擬瀏覽器進行網頁加載,當requests,url