当只发送邮件时,使用ssmtp作为Mail Transfer Agent非常方便.
一,安装
aptitude install ssmtp mailutils
二,配置
安装之后,需要更改两个文件。
首先更改文件/etc/ssmtp/ssmtp.conf,内容如下:
# # Config file for sSMTP sendmail # # The person who gets all mail for userids < 1000 # Make this empty to disable rewriting. root=自己邮箱地址 # The place where the mail goes. The actual machine name is required no # MX records are consulted. Commonly mailhosts are named mail.domain.com mailhub=邮箱imap服务器地址 # Where will the mail seem to come from? #rewriteDomain= # The full hostname hostname=主机名 # Are users allowed to set their own From: address? # YES - Allow the user to specify their own From: address # NO - Use the system generated From: address FromLineOverride=YES UseTLS=YES AuthUser=邮箱地址 AuthPass=邮箱密码
再更改文件/etc/ssmtp/revaliases,内容如下
# sSMTP aliases # # Format: local_account:outgoing_address:mailhub # # Example: root:your_login@your.domain:mailhub.your.domain[:port] # where [:port] is an optional port number that defaults to 25. root:自己的邮箱:邮箱imap服务器地址:端口 #如自己的邮箱是腾讯的企业邮箱: #root:自己邮箱:imap.exmail.qq.com:465
三,发送邮件:
echo "aaa" | mail -s "bbb" your_login@your.domain