Date: July 6, 2012//Category: Mail//No Comments
Before installing the mail server, you should know a few nouns and use them later:
| 123456 |
MUA:用户代理端,即用户使用的写信、收信客户端软件MTA:邮件传送端,即常说的邮件服务器,用于转发、收取用户邮件。MDA:邮件代理端,相当于MUA和MTA的中间人,可用于过滤垃圾邮件。POP:邮局协议,用于MUA连接服务器收取用户邮件,通信端口110。IMOP:互联网应用协议,功能较POP多,通信端口143。SMTP:简单邮件传送协议,MUA连接MTA或MTA连接MTA发送邮件使用此协议,通信端口25。 |
This configuration MTA takes postfix as an example, is simpler, more secure, and SendMail compatible with SendMail.
POSTFI Installation:
| 123 |
yum installpostfixyum remove sendmail/etc/init.d/postfixstart |
Postfix Master configuration settings:
| 1234567891011 |
cat/etc/postfix/ MAIN.CF myhostname = mail.haiyun.me #Mail服务器域名, ehlo name. mydomain = www.haiyun.me # myorigin = $mydomain # Sending address, this setting is displayed as @www.haiyun.me. inet_interfaces = All #如对外提供MTA服务设置为监听所有网卡, and only listens locally by default. inet_protocols = all #支持协议, optional Ipv4/ipv6. mydestination = $mydomain $myhostname #本地邮件域名, receive directly mynetworks_style = subnet #允许转发的来源网段, optional subnet subnet, class segment, host native mynetworks = 192.168.1.0/24,127.0.0.0/8 #允许转发的来源IP, ignoring mynetworks_style parameters after setting relay_domains = $mydestination #允许转发的目标域 smtpd_banner = $ Myhostname ESMTP "Mail Server" #自定服务器信息 |
Now postfix allow to receive or send mail:
| 123456 |
接收邮件:目的地为$inet_interfaces的邮件;目的地为$mydestination或$vitual_alias_maps的邮件。转发邮件:来源客户端符合$mynetworks的邮件;来源或目的为$relay_domains的邮件。 |
To configure mail aliases:
| 123 |
cat /etc/aliasestest:root,[email protected]别名:收件地址1,收件地址2 |
To update the alias database:
To configure mail forwarding:
| 12 |
cat ~/.forward[email protected],[email protected] |
Set the SMTP password authentication to prevent the MTA from being abused in Postfix with a configured trust segment, such as an external network that can use SMTP password authentication.
The system User password authentication, first start the SASLAUTHD service to assist Postfix system Password Authentication:
| 123 |
/etc/init.d/saslauthdstartchkconfig saslauthd onyum installcyrus-sasl-plain cyrus-sasl-md5 cyrus-sasl |
Determine that the SMTPD configuration file has the following contents:
| 12 |
cat /usr/lib/sasl2/smtpd.conf pwcheck_method: saslauthd #saslauthd协助smtp进行密码验证 |
Configure Postfix to use SASL authentication, edit MAIN.CF profile to add:
Test:testsaslautd-u username-p ' password '
| 1234567 |
smtpd_sasl_auth_enable = yes #开启SMTP验证smtpd_sasl_security_options = noanonymous #不允许匿名用户smtpd_recipient_restrictions = #接收者限制规则,按顺序执行 permit_mynetworks, #mynetworks用户通过,匹配结束 permit_sasl_authenticated, #sasl验证用户通过,匹配结束 reject_unknown_sender_domain, #拒绝无效的发送邮件域名 reject_unauth_destination #拒绝收件人非mydestination、relay_domains或virtual_alias_maps定义域邮件 |
To test whether SMTP authentication is in effect:
| 123456789101112131415 |
telnet localhost 25Trying ::1...Connected to localhost.Escape character is ‘^]‘.220 mail.domain.com ESMTP Postfixehlo localhost250-mail.domain.com250-PIPELINING250-SIZE 10240000250-VRFY250-ETRN250-AUTH LOGIN PLAIN #显示此信息代表验证正常250-ENHANCEDSTATUSCODES250-8BITMIME250 DSN |
Configure IMAP and POP:
To edit the dovecot configuration file:
| 123 |
vim /etc/dovecot/dovecot.conf protocols = imap pop3 #监听协议login_trusted_networks = 127.0.0.1 #允许登录接收邮件的IP段 |
To set up a mail directory:
| 12 |
cat /etc/dovecot/conf.d/10-mail.conf mail_location = mbox:~/mail:INBOX=/var/mail/%u |
New mail Account:
| 1 |
useradd -g mail -s /sbin/nologin user |
To start the Dovecot service:
| 1 |
/etc/init.d/dovecot start |
CentOS installation configuration Postfix mail server