这是我这几天来配置linux环境下的邮件服务器的汇总
首先介绍下环境与提前准备。
postfix 192.168.1.121
1.在自己的域名服务商添加 域名 与A记录,我的是内部测试也就在自己的内部DNS 上添加了 以下记录
IN MX 10 mail.ludy.com
mail IN A 192.168.6.121
这一步必须要做,不然就是你能发邮件到外部邮箱,但外部邮箱发不了给你。会提示找不到该域名
2. 安装软件 postfix dovecot-pop3d sasl2 因为我是ubuntu 我就懒点,编译安装就不多说了。
shell $> apt-get install sasl2-bin postfix dovecot-pop3d
3.修改 saslauthd 配置文件
shell $> vim /etc/default/saslauthd
START=yes
DESC="SASL Authentication Daemon"
NAME="saslauthd"
MECHANISMS="shadow"
MECH_OPTIONS=""
THREADS=5
OPTIONS="-c -m /var/spool/postfix/var/run/saslauthd"
4.重启 saslauthd 服务
shell $> /etc/init.d/saslauthd restart
ln -s /var/spool/postfix/var/run/saslauthd/ /var/run/saslauthd
## 不做这步操作,验证总是报错.
shell $> adduser postfix sasl
shell $> testsaslauthd -u root -p 123
0: OK "Success."
5. 配置 dovecot pop3服务
shell $> vim /etc/dovecot/dovecot.conf
protocols = pop3 pop3s
log_timestamp = "%Y-%m-%d %H:%M:%S "
disable_plaintext_auth = no
mail_privileged_group = mail
protocol imap {
}
protocol pop3 {
pop3_uidl_format = %08Xu%08Xv
}
protocol managesieve {
sieve=~/.dovecot.sieve
sieve_storage=~/sieve
}
auth default {
mechanisms = plain login
passdb pam {
}
userdb passwd {
}
user = root
socket listen {
client {
path = /var/spool/postfix/private/auth-client
mode = 0660
user = postfix
group = postfix
}
}
}
dict {
}
plugin {
}
6.重启 dovecot 服务
shell $> /etc/init.d/dovecot restart
7.测试 dovecot pop 服务
shell $> telnet localhost 110
Trying ::1...
Trying 127.0.0.1...
Connected to localhost.
Escape character is '^]'.
+OK Dovecot ready.
user yang1
+OK
pass ypmwbg
+OK Logged in.
quit
+OK Logging out.
quit
### logging 成功
8.配置 postfix 服务
shell $> vim /etc/postfix/main.cf
smtpd_banner = $myhostname ESMTP $mail_name (Ubuntu)
biff = no
append_dot_mydomain = no
readme_directory = no
smtpd_tls_cert_file=/etc/ssl/certs/ssl-cert-snakeoil.pem
smtpd_tls_key_file=/etc/ssl/private/ssl-cert-snakeoil.key
smtpd_use_tls=yes
smtpd_tls_session_cache_database = btree:${data_directory}/smtpd_scache
smtp_tls_session_cache_database = btree:${data_directory}/smtp_scache
myhostname = mail.ludy.com
mydomain = ludy.com
myorigin = $mydomain
alias_maps = hash:/etc/aliases
alias_database = hash:/etc/aliases
myorigin = /etc/mailname
mydestination = ludy.com, mail.ludy.com, localhost.ludy.com, , localhost
relayhost =
mynetworks = 127.0.0.0/8 [::ffff:127.0.0.0]/104 [::1]/128
mailbox_size_limit = 0
recipient_delimiter = +
inet_interfaces = all
smtpd_sasl_type = dovecot
smtpd_sasl_path = private/auth-client
smtpd_sasl_auth_enable = yes
smtpd_recipient_restrictions = permit_sasl_authenticated,permit_mynetworks,reject_unauth_destination
修改 master.cf
shell $> vim master.cf
smtp inet n - - - - smtpd
替换为
smtp inet n - n - - smtpd
9.重启 postfix 服务
/etc/init.d/postfix restart
10.测试 postfix 服务smtp
shell $> telnet localhost 25
Trying ::1...
Trying 127.0.0.1...
Connected to localhost.
Escape character is '^]'.
220 mail.ludy.com ESMTP Postfix (Ubuntu)
ehlo mail.ludy.com
250-mail.ludy.com
250-PIPELINING
250-SIZE 10240000
250-VRFY
250-ETRN
250-STARTTLS
250-AUTH PLAIN LOGIN
250-ENHANCEDSTATUSCODES
250-8BITMIME
250 DSN
quit
11.添加用户
shell $> adduser yang1
shell $> adduser yang2
##密码大家自己记得啊。
12. FOXMAIL测试
打开帐号管理,添加帐号
设置 pop3 服务器,由于我们都安装在了一台机器上,都是一个mail.mplite.com
然后同样的操作,再添加 yang2 这个用户,以便我们发收信建做测试.
发信测试:
点击收取,查看yang2的收件箱
收到了!接下来就可以测试发送/接收外部邮箱的邮件了!