NAME
mail - send and receive mail
SYNOPSIS
mail [-iInv] [-s subject] [-c cc-addr] [-b bcc-addr] to-addr... [-- sendmail-options...]
mail [-iInNv] -f [name]
mail [-iInNv] [-u user]
具體的用法還得查看man mail
===root用戶使用mail命令發一封郵件到139郵箱===
mail -s "subject" [email protected] << EOF |
擴展一下:最近發現一個問題,nagios賬號使用這個命令發郵件給139郵箱會產生郵件隊列。呵呵,可能139已經將[email protected] 做了相關處理,錯誤提示形如
p0D20IWk015445 244 Thu Jan 13 10:00 <[email protected]> (Deferred: Connection reset by mx.139.com.) |
解決方法
mail -s "subject" [email protected] << EOF -- -f otheruser@localhost.localdomain hi,139 EOF |
===查看隊列===
mailq # 查看MTA隊列的滯留情況(等價於sendmail -bp) mailq -Ac # 查看MSP隊列的滯留情況(等價於sendmail -bp -Ac) |
===強制送信===
/usr/sbin/sendmail -q -v # 對MTA隊列強制送信 /usr/sbin/sendmail -q -v -Ac # 對MSP隊列強制送信 |
參數說明:
-q 立即處理隊列的內容.
-v 顯示進度詳細信息
-Ac 讀取MSP隊列(默認是讀取MTA隊列)
===清除隊列郵件===
cd /var/spool/mqueue/ rm -f qfp0D* |
*******/var/spool/mqueue/下一些文件的說明*********
df:郵件內容
qf:郵件頭和一些控制信息
xf:一些臨時文件
tf:qf文件的臨時存儲文件
===sendmail啓動慢===
修改/etc/hosts文件,建議格式形如:
- 127.0.0.1 localhost.localdomain localhost x.localhost.localdomain
===命令行下發送附件===
yum -y install sharutils
example,
cat file | uuencode file |mail -s "title" [email protected]
有一篇關於sendmail的文章很好
http://www.db110.com/?p=1978
---------------------telnet host 25 ---------------------
helo ##****************************************##
mail from: [email protected]
rcpt [email protected]
data
.
quit
date內容相關格式
mime-version: 1.0
from: [email protected]
to: [email protected]
cc: [email protected]
subject: helo
Content-Type: text/plain;charset="GB2312"