postfix和dovecot架设邮件服务器的一些记录1

安装postfix,就用centos6.7附带的,直接在图形界面的管理的软件追加的服务器项目里的邮件服务器,添加postfix相关的,以及dovecot,为了收信嘛。当然因为sendmail和postfix只能有一个存在,安装postfix的时候,把sendmail相关都去掉。这样最简单,不需要修改系统默认的MTA,安装的过程中就自动修改了。

也可以通过命令

alternatives --config mta

来修改。

然后可以在图形管理界面的服务里把postfix和dovecot变成自动执行,并且都启动起来。运行级别3以上都要选上。如果要使用认证发信,那么必须把saslauthd变成自动执行,默认不是自动启动。

当然如果非要用命令

chkconfig postfix on
也行


最初建立最为简单的单域email服务器,直接使用Linux系统账户作为用户,这样配置修改最少。

先用命令行看看现在postfix的配置情况

postconf -n

这个命令显示配置的和默认不同的部分,如果要看全部不要用-n就全部显示出来

alias_database = hash:/etc/aliases //这个是别名的数据库
alias_maps = hash:/etc/aliases //别名对应列表
broken_sasl_auth_clients = yes //对于老式的email客户端是不是对应,就是不遵守RFC规则的
command_directory = /usr/sbin
config_directory = /etc/postfix
daemon_directory = /usr/libexec/postfix
data_directory = /var/lib/postfix
debug_peer_level = 2
home_mailbox = Maildir/  //这个是指定每个用户邮件的形式,这样指定是每一封信是一个文件,用户的email放在/home/username/Maildir下面

html_directory = no
inet_interfaces = all  //默认是localhost,如果要对外运行,必须修改
inet_protocols = all
mail_owner = postfix
mail_spool_directory = /var/spool/mail  //线程缓存交换的目录
mailq_path = /usr/bin/mailq.postfix
manpage_directory = /usr/share/man
mydestination = $mydomain //需要接受信的域名
mydomain = shenxu.com  //自己的域名
mynetworks = 127.0.0.0/8  //指定内网或者可以信任的网络地址
myorigin = $mydomain  //本域,如果发信的没有带自己的域,就在后面挂上这个
newaliases_path = /usr/bin/newaliases.postfix
queue_directory = /var/spool/postfix
readme_directory = /usr/share/doc/postfix-2.6.6/README_FILES
sample_directory = /usr/share/doc/postfix-2.6.6/samples
sender_canonical_maps = hash:/etc/postfix/sender_canonical_maps  //替换发信者的映射列表
sendmail_path = /usr/sbin/sendmail.postfix
setgid_group = postdrop
smtpd_client_restrictions = permit_mynetworks, check_client_access hash:/etc/postfix/access, permit_sasl_authenticated  //允许那些客户端可以接入,这里可以用来反垃圾邮件,如:reject_rbl_client zen.spamhaus.org 后面的域名是反垃圾邮件组织的域名

smtpd_recipient_restrictions = permit_mynetworks,permit_sasl_authenticated, reject_unauth_destination  //中继email的许可范围
smtpd_sasl_auth_enable = yes //可以进行发信认证
smtpd_sender_restrictions = check_sender_access hash:/etc/postfix/sender_access, permit_sasl_authenticated //发信者的确认

unknown_local_recipient_reject_code = 550

其实默认的一些也很重要

smtpd_sasl_path = smtpd  //这个是使用系统默认的路径

smtpd_sasl_security_options = noanonymous //禁止匿名认证

smtpd_sasl_type = cyrus //这个是使用系统默认的用户认证方式

这个默认是这样的,所以不需要修改,有时候为了和dovecot配合认证

smtpd_sasl_type = dovecot
smtpd_sasl_path = private/auth

当然如果dovecot也是用的默认的,没必要改,一般是要用到虚拟域的时候,无法使用Linux账户进行身份认证的时候才进行修改。


下面在看一下默认的dovecot

dovecot -n

# 2.0.9: /etc/dovecot/dovecot.conf
# OS: Linux 2.6.32-573.22.1.el6.x86_64 x86_64 CentOS release 6.7 (Final)
auth_mechanisms = plain login //认证的基本两种方法,必须要有,其它复杂的不提
disable_plaintext_auth = no  //必须要no掉,不然老的客户端没法进行身份认证
managesieve_notify_capability = mailto
managesieve_sieve_capability = fileinto reject envelope encoded-character vacation subaddress comparator-i;ascii-numeric relational regex imap4flags copy include variables body enotify environment mailbox date
mbox_write_locks = fcntl
passdb {
  driver = pam    //支持系统身份认证
}
plugin {
  sieve = ~/.dovecot.sieve
  sieve_dir = ~/sieve
}
protocols = imap pop3 //支持的协议
ssl_cert = </etc/pki/dovecot/certs/dovecot.pem  //进行电子证书的文件
ssl_key = </etc/pki/dovecot/private/dovecot.pem  //进行电子证书的文件

userdb {
  driver = passwd  //支持系统身份认证

}

这个内容的修改,因为版本提高的原因,有些已经不在/etc/dovecot/dovecot.conf里了,而是在/etc/dovecot/conf.d下面的诸多文件里,修改的时候需要一个一个的修改。

比如disable_plaintext_auth = no是在10-auth.conf文件里,不过大多是不需要修改的。

/etc/dovecot/dovecot.conf就只修改了protocols = imap pop3一处,总共就改了2处,就可以用,架设服务器很快。

如果在postfix里修改了认证方式smtpd_sasl_type = dovecot,那么对应的dovecot也需要做相应的修改,/etc/dovecot/conf.d/10-master.conf

service auth {

  unix_listener auth-userdb {

  }

  unix_listener /var/spool/postfix/private/auth {

    mode = 0666

    user = postfix

    group = postfix

  }


你可能感兴趣的:(postfix)