CentOS下配置SMTP

來源:互聯網
上載者:User

標籤:connect   create   creat   軟體包   x86_64   sys   root   update   是什麼   

在伺服器上配置一個SMTP郵件服務可能是在日常工作中經常會遇到的需要,比如在做一些簡單測試的時候。

配置步驟無比簡單,廢話不說:

1,yum -y install mail

2,編輯/etc/mail.rc,配置一些smtp相關內容

3,沒有了...

安裝mail

詳細輸出過程,記錄如下

[[email protected] ~]# yum -y install mail已載入外掛程式:fastestmirror設定安裝進程Loading mirror speeds from cached hostfileCould not get metalink https://mirrors.fedoraproject.org/metalink?repo=epel-6&arch=x86_64 error was14: Peer cert cannot be verified or peer cert invalid* base: mirrors.yun-idc.com* epel: mirror.lzu.edu.cn* extras: mirrors.yun-idc.com* updates: mirrors.yun-idc.combase | 3.7 kB 00:00extras | 3.4 kB 00:00updates | 3.4 kB 00:00解決依賴關係--> 執行事務檢查---> Package mailx.x86_64 0:12.4-8.el6_6 will be 安裝--> 完成依賴關係計算依賴關係解決===============================================================================================================================================================================================軟體包 架構 版本 倉庫 大小===============================================================================================================================================================================================正在安裝:mailx x86_64 12.4-8.el6_6 base 235 k事務概要===============================================================================================================================================================================================Install 1 Package(s)總下載量:235 kInstalled size: 452 k下載軟體包:mailx-12.4-8.el6_6.x86_64.rpm | 235 kB 00:00運行 rpm_check_debug執行事務測試事務測試成功執行事務正在安裝 : mailx-12.4-8.el6_6.x86_64 1/1warning: /etc/mail.rc created as /etc/mail.rc.rpmnewVerifying : mailx-12.4-8.el6_6.x86_64 1/1已安裝:mailx.x86_64 0:12.4-8.el6_6完畢![[email protected] ~]#  
配置SMTP
[[email protected] ~]# vim /etc/mail.rc[[email protected] ~]# cat /etc/mail.rcset [email protected]set smtp=smtp.163.comset smtp-auth-user=my_test_mail_addressset smtp-auth-password=passwd_of_my_test_mail_address123set smtp-auth=login[[email protected] ~]#
測試
[[email protected] ~]# echo "hehe" | mailx -v -s "test" [email protected]Resolving host smtp.163.com . . . done.Connecting to 220.181.12.16 . . . connected.220 163.com Anti-spam GT for Coremail System (163com[20141201])>>> EHLO thatsit250-mail250-PIPELINING250-AUTH LOGIN PLAIN250-AUTH=LOGIN PLAIN250-coremail 1Uxr2xKj7kG0xkI17xGrU7I0s8FY2U3Uj8Cz28x1UUUUU7Ic2I0Y2UrKfWhDUCa0xDrUUUUj250-STARTTLS250 8BITMIME>>> AUTH LOGIN334 dXNlcm5hbWU6>>> dGhhdHNtYWls334 UGFzc3dvcmQ6>>> IUAjdGhhdHNtYWlsMTIz235 Authentication successful>>> MAIL FROM:<[email protected]>250 Mail OK>>> RCPT TO:<[email protected]>250 Mail OK>>> DATA354 End data with <CR><LF>.<CR><LF>>>> .250 Mail OK queued as smtp12,EMCowADX78NadypYg6vqDA--.33888S2 1479178081>>> QUIT221 Bye[[email protected] ~]#

  

mailx和mail的關係

這裡大家可能也看到了,上面測試命令裡用了mailx,跟有些文檔裡用的mail命令不一樣,那麼這兩者之間的關係是什麼呢?我們來看一下:

[[email protected] ~]# which mail/bin/mail[[email protected] ~]# ll /bin/maillrwxrwxrwx 1 root root 22 11月 15 10:47 /bin/mail -> /etc/alternatives/mail[[email protected] ~]# ll /etc/alternatives/maillrwxrwxrwx 1 root root 10 11月 15 10:47 /etc/alternatives/mail -> /bin/mailx[[email protected] ~]#

大家也看到了,其實mail就是mailx軟鏈的軟鏈。因此在使用上,這兩個命令一樣的:

[[email protected] ~]# echo "hehe" | mail -v -s "test" [email protected]Resolving host smtp.163.com . . . done.Connecting to 220.181.12.11 . . . connected.220 163.com Anti-spam GT for Coremail System (163com[20141201])>>> EHLO thatsit250-mail250-PIPELINING250-AUTH LOGIN PLAIN250-AUTH=LOGIN PLAIN250-coremail 1Uxr2xKj7kG0xkI17xGrU7I0s8FY2U3Uj8Cz28x1UUUUU7Ic2I0Y2UFbVUZKUCa0xDrUUUUj250-STARTTLS250 8BITMIME>>> AUTH LOGIN334 dXNlcm5hbWU6>>> dGhhdHNtYWls334 UGFzc3dvcmQ6>>> IUAjdGhhdHNtYWlsMTIz235 Authentication successful>>> MAIL FROM:<[email protected]>250 Mail OK>>> RCPT TO:<[email protected]>250 Mail OK>>> DATA354 End data with <CR><LF>.<CR><LF>>>> .250 Mail OK queued as smtp7,C8CowAD3FNqqeSpYj9soDQ--.40085S2 1479178674>>> QUIT221 Bye[[email protected] ~]# 

 

兩封測試郵件的如下

 

DONE

CentOS下配置SMTP

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.