有的時候需要使用本地的mail,來對外網發送郵件,需要定制mail的smtp伺服器。
bin/mail會預設使用本地sendmail發送郵件,這樣要求本地的機器必須安裝和啟動Sendmail服務,配置非常麻煩,而且會帶來不必要的
資源占用。而通過修改配置檔案可以使用外部SMTP伺服器,可以達到不使用sendmail而用外部的smtp伺服器發送郵件的目的:
修改/etc/mail.rc
set [email protected] smtp=smtp.domain.com
set smtp-auth-user=username smtp-auth-password=passwor smtp-auth=login
說明:
from是發送的郵件位址
smtp是發生的外部smtp伺服器的位址
smtp-auth-user是外部smtp伺服器認證的使用者名
smtp-auth-password是外部smtp伺服器認證的使用者密碼
smtp-auth是郵件認證的方式
配置成功後,就可以使用了
可以發送一封郵件測試一下:
mail -s "test" [email protected] <content.txt 其中-s後面的是郵件标題,[email protected]是收件人位址,content.txt裡面是郵件正文