Linux msmtp+mail郵件發送


 用msmtp+mail 來發郵件竟然比 msmtp+mutt還要簡單

第一步 先把 msmtp 安裝好
tar xf msmtp-1.4.17.tar.bz2
cd msmtp-1.4.17
./configure --prefix=/usr/local/msmtp
make
make install
cd /usr/local/msmtp/
mkdir etc
cd etc
vi msmtprc #手動建立配置文件
account default
host smtp.qiye.163.com #163企業郵箱的smtp服務器
port 25
from [email protected]      #公司企業郵箱總會有吧!讓公司網關給你開個專用的郵箱用來發郵件
auth login
tls off
user [email protected]
password 1234
logfile /var/log/mmlog

保存退出
好了,測試一下 /usr/local/msmtp/bin/msmtp [email protected]
隨便輸入一些內容 然後按 ctrl+d 退出,看看是否收到郵件,發件人是不是 [email protected],收到後則一切正常。
最後再做一步,就能讓 mail 利用msmtp 發送郵件了。
修改 /etc/mail.rc 在裏面加入一條 ,或者在發送郵件的用戶 的 home目錄下 增加一個 .mailrc (注意中間沒有 ".") 的文件插入下面一行:
set sendmail="/usr/local/msmtp/bin/msmtp"
保存退出,測試下 echo "this is a test mail" | mail -s "TEST mail" [email protected]
去郵箱看看是否收到郵件。注意 這樣修改以後 mail 的log 不會寫在 /var/log/maillog 上了,而是會在 /var/log/mmlog
呵呵簡單吧!只需要一行就可以了。msmtp 的官網上是這麼寫的
10.4 Using msmtp with mail

Define a default account, and put the following into ~/.mailrc:

     set sendmail="/path/to/msmtp"
You need to define a default account, because mail does not allow extra options to the msmtp command line.

呵呵,快去試試吧~~~


下面是我的msmtprc

defaults


logfile /usr/local/msmtp/msmtp.log
# The SMTP server of the provider.
account test


# SMTP郵件服務器地址
host smtp.qq.com


# 發送的郵件Email
from   @qq.com
auth login


# 郵件服務器登錄賬號
user     @qq.com


# 郵件服務器登陸密碼
password ********
# Set a default account
account default : test



發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章