首先使用yum -y install dovecot* postfix* 来安装邮件服务器,然后...
按下面提供代码配置服务器后,剩下的就是创建用户与解析域名啦...
【建立用户的邮箱目录】
首先建立用户模板下的邮箱目录,以便于建立新用户时,相应用户的邮箱目录自动被建立。
[root@szzmzb.com ~]# mkdir /etc/skel/Maildir ← 在用户模板下建立用户邮箱目录
[root@szzmzb.com ~]# chmod 700 /etc/skel/Maildir ← 设置用户邮箱目录属性为700
然后再为已经存在的用户建立相应邮箱目录。
[root@szzmzb.com ~]# mkdir /home/webmaster/Maildir ← 为用户(这里以webmaster用户为例)建立邮箱目录
[root@szzmzb.com ~]# chmod 700 /home/webmaster/Maildir ← 设置该用户邮箱目录属性为700
[root@szzmzb.com ~]# chown webmaster. /home/webmaster/Maildir ← 设置该用户邮箱目录为该用户所有
【添加用户示例】
①添加用户:useradd -G 用户组 -s /sbin/nologin 用户名
②设置用户密码:passwd 用户名
③添加用户的sasl认证:saslpasswd2 -u szzmzb.com -c 用户名
【解析域名示例】
主机名 解析类型 对应值 TTL 优先级 操作
www A 113.105.117.2 900 - 修改 | 删除
mail A 113.105.117.2 900 - 修改 | 删除
@ MX mail.szzmzb.com. 900 10 修改 | 删除
源码与演示:
1. [代码]
postfix配置
## 不懂的直接 vim /etc/postfix/main.cf 然后复制下面代码到你的服务器上,修改下相应的IP与域名即可
02#============================基本配置=============================================================
03queue_directory = /var/spool/postfix
04command_directory = /usr/sbin
05daemon_directory = /usr/libexec/postfix
06data_directory = /var/lib/postfix
07mail_owner = postfix
08myhostname = mail.szzmzb.com
09mydomain = szzmzb.com
10myorigin = $mydomain
11inet_interfaces = all
12inet_protocols = all
13mydestination = $myhostname, localhost.$mydomain, localhost, $mydomain
14unknown_local_recipient_reject_code = 550
15#mynetworks = 0.0.0.0/0, 192.168.0.0/24, 127.0.0.0/8, 113.105.117.2
16mynetworks = 192.168.0.0/24, 127.0.0.0/8
17relay_domains = $mydestination
18alias_maps = hash:/etc/aliases
19alias_database = hash:/etc/aliases
20home_mailbox = Maildir/
21
22smtpd_banner = $myhostname ESMTP unknow
23#smtpd_banner = $myhostname ESMTP $mail_name ($mail_version)
24smtpd_sasl_auth_enable = yes
25smtpd_delay_reject = no
26smtpd_sasl_local_domain = $myhostname
27smtpd_sasl_security_options = noanonymous
28#smtpd_recipient_restrictions = permit_mynetworks, permit_sasl_authenticated, reject_unauth_destination,reject_unknown_sender_domain, reject_unknown_hostname,reject_unauth_destination
29smtpd_recipient_restrictions = permit_mynetworks, permit_sasl_authenticated, reject_unauth_destination
30
31debug_peer_level = 2
32debugger_command =
33PATH=/bin:/usr/bin:/usr/local/bin:/usr/X11R6/bin
34ddd $daemon_directory/$process_name $process_id & sleep5
2. [代码]
dovecot配置
## 不懂的直接 vim /etc/dovecot/dovecot.conf 然后复制下面代码到你的服务器上,修改下相应的IP与域名即可
02## Dovecot configuration file
03# Protocols we want to be serving.
04protocols = imap pop3
05log_path = /var/log/dovecot.log
06info_log_path = /var/log/dovecot.info
07log_timestamp = "%Y-%m-%d %H:%M:%S "
08
09# edit conf.d/master.conf.
10listen = *
11disable_plaintext_auth = no
12ssl=no
13mail_location = maildir:~/Maildir
14#default_mail_env = maildir:~/Maildir
15base_dir = /var/run/dovecot/
16# Greeting message for clients.
17#login_greeting = Dovecot ready.
18
19#login_trusted_networks = 0.0.0.0/0
20
21#login_access_sockets =
22#verbose_proctitle = no
23#shutdown_clients = yes
24#doveadm_socket_path = doveadm-server
25
26dict {
27#quota = mysql:/etc/dovecot/dovecot-dict-sql.conf.ext
28#expire = sqlite:/etc/dovecot/dovecot-dict-sql.conf.ext
29}
30
31!include conf.d/*.conf
32
33#!include_try /etc/dovecot/local.conf