Xiaopei's DokuWiki

These are the good times in your life,
so put on a smile and it'll be alright

User Tools

Site Tools


it:linux:sendmail

sendmail

选择 MTA 和 SMTP Server

Linux 中 sendmail 的选择很多:

$ sendmail
The program 'sendmail' can be found in the following packages:
 * exim4-daemon-heavy
 * exim4-daemon-light
 * postfix
 * citadel-mta
 * courier-mta
 * dma
 * esmtp-run
 * lsb-invalid-mta
 * masqmail
 * msmtp-mta
 * nullmailer
 * qmail-run
 * sendmail-bin
 * ssmtp
 * xmail
Try: apt-get install <selected package>

其中一些仅是 MTA, 另一些既是 SMTP server 又是 MTA. 经过一些对比, 目前(2012/10/27):

  • 若只作 MTA(通过第三方 SMTP server 发信) 最合适的轻量级选择是 msmtp
  • 若服务器自身发信, 则最合适的是 postfix

postfix

deb 安装 postfix 时会提示选择服务器类型和设置 mailname.

如果之前安装过 sendmail, 那么安装 postfix 后, 发件时可能产生错误 “postdrop: warning: unable to look up public/pickup: No such file or directory”. It turns out to be sendmail running along with Postfix and creating issues. The fix is to stop/remove sendmail and create the necessary postfix directory and restart the postfix service.

# /etc/init.d/sendmail stop 
# mkfifo /var/spool/postfix/public/pickup
# /etc/init.d/postfix restart

LinuxHostingSupport » Postfix postdrop: unable to look up public/pickup: No such file or directory

msmtp

.msmtprc
# Accounts will inherit settings from this section
defaults
auth             on
tls              on
tls_trust_file   /usr/share/ca-certificates/mozilla/Thawte_Premium_Server_CA.crt
 
# A first gmail address
account        gmail
host           smtp.gmail.com
port           587
from           username@gmail.com
user           username@gmail.com
password       password
tls_trust_file /etc/ssl/certs/ca-certificates.crt
 
# A second gmail address
account    gmail2 : gmail
from       username2@gmail.com
user       username2@gmail.com
password   password2
 
# A freemail service
account    freemail
host       smtp.freemail.example
from       joe_smith@freemail.example
user       joe.smith
password   secret
 
# A provider's service
account   provider
host      smtp.provider.example
 
# Set a default account
account default : gmail

msmtp - ArchWiki

mailname

客户服务器都需要部署 sendmail, 但默认配置下往往发出的邮件会收不到, 这很可能是因为 sendmail 时用的是 hostname, 如 foo@ubuntu, 被认为是 spam 而拒收造成的.

解决办法就是设置 mailname.

设置分两步:

  1. 新建 /etc/mailname, 填写域名, 如 example.com
  2. 修改 /etc/hosts, 将域名加到 127.0.1.1 中, 让本地知道这是自己的名字

http://wiki.debian.org/EtcMailName

it/linux/sendmail.txt · Last modified: 2013/08/19 07:22 (external edit)