參考資料:html
http://coolnull.com/2614.htmlmysql
linux自帶的mail能夠實現外部smtp發郵件。不須要本地配置postfix,sendmail郵件服務器,配置整套下來確實須要點時間。linux
環境:sql
IP服務器 |
主機名工具 |
操做系統post |
備註測試 |
192.168.120.130spa |
db130操作系統 |
CentOS release 6.10 (Final) |
service sendmail stop chkconfig sendmail off service postfix stop chkconfig postfix off # 須要安裝這個工具 yum -y install mail
服務器地址: POP3服務器: pop.163.com SMTP服務器: smtp.163.com IMAP服務器: imap.163.com
增長一下相似N行,指定外部的smtp服務器地址、賬號密碼等。
cp /etc/mail.rc /etc/mail.rc.bak.`date +%Y%m%d%H` [root@db130 ~]# cat /etc/mail.rc # 新增以下內容 ################ # add new context: set from=13439017540@163.com set smtp=smtp.163.com set smtp-auth-user=13439017540@163.com set smtp-auth-password=xxxxx set smtp-auth=login # 保存後退出,測試發送郵件 echo "hello" | mail -s "Title" 13439017540@163.com 根據網速、運營商、SMTP的狀況不一樣,郵件發送將有延遲現象。 # 沒有附件的發送 [root@db130 yum.repos.d]# echo hello word | mailx -v -s " title" 13439017540@163.com Resolving host smtp.163.com . . . done. Connecting to 220.181.12.17 . . . connected. 220 *********************************************************** >>> EHLO db130 250-mail 250-PIPELINING 250-AUTH LOGIN PLAIN 250-AUTH=LOGIN PLAIN 250-XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXA 250-XXXXXXXB 250 8BITMIME >>> AUTH LOGIN 334 dXNlcm5hbWU6 >>> MTM0MzkwMTc1NDBAMTYzLmNvbQ== 334 UGFzc3dvcmQ6 >>> TFdXMTM0NTQw 235 Authentication successful >>> MAIL FROM:<13439017540@163.com> 250 Mail OK >>> RCPT TO:<13439017540@163.com> 250 Mail OK >>> DATA 354 End data with <CR><LF>.<CR><LF> >>> . 250 Mail OK queued as smtp13,EcCowAD3rB23TI9bpLofDA--.36134S2 1536117944 >>> QUIT 221 Bye [root@db130 yum.repos.d]# #帶有附件的發送方式 mailx -v -s "title3" 13439017540@163.com </root/INSTALL.mysql.sh