Debian上的Postfix + Courier IMAP + MySQL + SASL + TLS

时间:2020-03-21 11:46:36  来源:igfitidea点击:

在Debian Wheezy上设置Postfix。

准备工作

这些是将用于配置的详细信息:

域:igi.test(mail.igi.test)
MX:mx1.igi.test
电子邮件帐户:Hyman @ theitroad
MySQL数据库:后缀
MySQL用户:邮件
MySQL密码:passwd

如果我们觉得更好,请用example.com替换igi.test。

我们可能想要这样:

# apt-get install vim

MySQL

安装MySQL。
系统将要求我们输入MySQL根密码。
确保记住它。

# apt-get install mysql-client mysql-server

为Postfix创建mysql数据库和用户。
随时更改“ passwd”密码字段:

# cat > ./create.sql << EOF
CREATE DATABASE postfix;
GRANT ALL PRIVILEGES ON postfix.* TO "mail"@"localhost" IDENTIFIED BY "passwd";
FLUSH PRIVILEGES;
EOF

导入:

# mysql -u root -p < ./create.sql

为Postfix创建数据库表:

# cat > postfix-mysql.sql << EOL
# Based on http://flurdy.com/docs/postfix/#config-simple-database
USE postfix;
CREATE TABLE aliases (
 pkid smallint(3) NOT NULL auto_increment,
 mail varchar(120) NOT NULL default '',
 destination varchar(120) NOT NULL default '',
 enabled tinyint(1) NOT NULL default '1',
 PRIMARY KEY  (pkid),
 UNIQUE KEY mail (mail)
);
CREATE TABLE domains (
 pkid smallint(6) NOT NULL auto_increment,
 domain varchar(120) NOT NULL default '',
 transport varchar(120) NOT NULL default 'virtual:',
 enabled tinyint(1) NOT NULL default '1',
 PRIMARY KEY  (pkid)
);
CREATE TABLE users (
 id varchar(128) NOT NULL default '',
 name varchar(128) NOT NULL default '',
 uid smallint(5) unsigned NOT NULL default '5000',
 gid smallint(5) unsigned NOT NULL default '5000',
 home varchar(255) NOT NULL default '/var/spool/mail/virtual',
 maildir varchar(255) NOT NULL default 'blah/',
 enabled tinyint(1) NOT NULL default '1',
 change_password tinyint(1) NOT NULL default '1',
 clear varchar(128) NOT NULL default 'changemepls',
 crypt varchar(128) NOT NULL default 'V2VkIE9jdCAyOSAxMzo1MD',
 quota varchar(255) NOT NULL default '',
 PRIMARY KEY  (id),
 UNIQUE KEY id (id)
);
EOL
# mysql -u mail -p < ./postfix-mysql.sql

启用MySQL日志记录以对Postfix设置进行故障排除。
打开'/etc/mysql/my.cnf'并取消注释:

general_log_file = /var/log/mysql/mysql.log
general_log = 1

重新启动MySQL:

# /etc/init.d/mysql restart

postfix

安装Postfix。
询问时选择互联点。

# apt-get install postfix postfix-mysql

设置用于存储虚拟邮件的文件夹等。

# cp /etc/aliases /etc/postfix/aliases
# postalias /etc/postfix/aliases
# mkdir /var/spool/mail/virtual
# groupadd --system virtual -g 5000
# useradd --system virtual -u 5000 -g 5000
# chown -R virtual:virtual /var/spool/mail/virtual

这是我们当前的Postfix配置的样子:

# cat /etc/postfix/main.cf
myorigin = /etc/mailname
smtpd_banner = $myhostname ESMTP $mail_name
biff = no
relayhost = 
inet_interfaces = all
mynetworks_style = host
inet_protocols = ipv4
append_dot_mydomain = no
delay_warning_time = 4h
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
smtpd_relay_restrictions = permit_mynetworks permit_sasl_authenticated defer_unauth_destination
alias_maps = hash:/etc/postfix/aliases
alias_database = hash:/etc/postfix/aliases
# this specifies where the virtual mailbox folders will be located
virtual_mailbox_base = /var/spool/mail/virtual
# this is for the mailbox location for each user
virtual_mailbox_maps = mysql:/etc/postfix/mysql_mailbox.cf
# and this is for aliases
virtual_alias_maps = mysql:/etc/postfix/mysql_alias.cf
# and this is for domain lookups
virtual_mailbox_domains = mysql:/etc/postfix/mysql_domains.cf
virtual_uid_maps = static:5000
virtual_gid_maps = static:5000
# Will be using virtual domains
local_recipient_maps =
mydestination =
mynetworks = 127.0.0.0/8 [::ffff:127.0.0.0]/104 [::1]/128
mailbox_size_limit = 0
recipient_delimiter = +
# will it be a permanent error or temporary
unknown_local_recipient_reject_code = 450
# how long to keep message on queue before return as failed.
# some have 3 days, I have 16 days as I am backup server for some people
# whom go on holiday with their server switched off.
maximal_queue_lifetime = 7d
# max and min time in seconds between retries if connection failed
minimal_backoff_time = 1000s
maximal_backoff_time = 8000s
# how long to wait when servers connect before receiving rest of data
smtp_helo_timeout = 60s
# how many address can be used in one message.
# effective stopper to mass spammers, accidental copy in whole address list
# but Jan restrict intentional mail shots.
smtpd_recipient_limit = 10
# how many error before back off.
smtpd_soft_error_limit = 3
# how many max errors before blocking it.
smtpd_hard_error_limit = 12
# Requirements for the HELO statement
smtpd_helo_restrictions = permit_mynetworks, warn_if_reject reject_non_fqdn_hostname, reject_invalid_hostname, permit
# Requirements for the sender details
smtpd_sender_restrictions = permit_mynetworks, warn_if_reject reject_non_fqdn_sender, reject_unknown_sender_domain, reject_unauth_pipelining, permit
# Requirements for the connecting server 
smtpd_client_restrictions = reject_rbl_client sbl.spamhaus.org, reject_rbl_client blackholes.easynet.nl
# Requirement for the recipient address
smtpd_recipient_restrictions = reject_unauth_pipelining, permit_mynetworks, reject_non_fqdn_recipient, reject_unknown_recipient_domain, reject_unauth_destination, permit
smtpd_data_restrictions = reject_unauth_pipelining
# require proper helo at connections 
smtpd_helo_required = yes
# waste spammers time before rejecting them
smtpd_delay_reject = yes
disable_vrfy_command = yes

Postfix的MySQL配置

设置文件以通过数据库访问查找。

# cat > /etc/postfix/mysql_mailbox.cf << EOL
user=mail
password=passwd
dbname=postfix
table=users
select_field=maildir
where_field=id
hosts=127.0.0.1
additional_conditions = and enabled = 1
EOL

如何查找电子邮件别名。

# cat > /etc/postfix/mysql_alias.cf << EOL
user=mail
password=passwd
dbname=postfix
table=aliases
select_field=destination
where_field=mail
hosts=127.0.0.1
additional_conditions = and enabled = 1
EOL

如何查找域。

# cat > /etc/postfix/mysql_domains.cf << EOL
user=mail
password=passwd
dbname=postfix
table=domains
select_field=domain
where_field=domain
hosts=127.0.0.1
additional_conditions = and enabled = 1
EOL

以下内容阻止世界阅读包含MySQL凭据的Postfix文件。

# chown root:postfix /etc/postfix/mysql_*
# chmod 0640 /etc/postfix/mysql_*

将用户添加到MySQL

重要域和用户。

# cat > ./required.sql << EOL
USE postfix;
INSERT INTO domains (domain) VALUES ('localhost'), ('localhost.localdomain');
INSERT INTO aliases (mail,destination) VALUES
 ('Hyman@theitroad','Hyman@theitroad'),
 ('Hyman@theitroad','Hyman@theitroad'),
 ('Hyman@theitroad','Hyman@theitroad'),
 ('Hyman@theitroad','Hyman@theitroad'),
 ('Hyman@theitroad','Hyman@theitroad'),
 ('@localhost','Hyman@theitroad'),
 ('@localhost.localdomain','@localhost');
INSERT INTO users (id,name,maildir,crypt) VALUES
 ('Hyman@theitroad','root','root/',encrypt('rootpasswd', CONCAT('$', MD5(RAND()))) );
EOL

导入:

$mysql -u mail -p < ./required.sql

我们需要添加我们的域:

mysql> INSERT INTO domains (domain) VALUES ('igi.test');

和一个电子邮件用户(长行):

mysql> INSERT INTO users (id,name,maildir,crypt) VALUES ('Hyman@theitroad','igi','igi/',encrypt('passwd', CONCAT('$', MD5(RAND()))) );

删除记录:

mysql> DELETE FROM users WHERE name="igi";

重新启动Postfix。

# service postfix restart

速递IMAP

安装:

# apt-get install courier-base courier-authdaemon courier-authlib-mysql \
courier-imap courier-imap-ssl courier-ssl

打开“/etc/courier/imapd”并更改以下内容:

ADDRESS=0

ADDRESS=0.0.0.0

这将使Courier IMAP仅在IPv4上侦听。

“/etc/courier/authdaemonrc”文件的外观如下:

# grep -ve "^#" -ve "^$" /etc/courier/authdaemonrc
authmodulelist="authmysql"
authmodulelistorig="authuserdb authpam authpgsql authldap authmysql authcustom authpipe"
daemons=5
authdaemonvar=/var/run/courier/authdaemon
DEBUG_LOGIN=2
DEFAULTOPTIONS=""
LOGGEROPTS=""

“/etc/courier/authmysqlrc”文件的外观如下:

# grep -ve "^#" -ve "^$" /etc/courier/authmysqlrc
MYSQL_SERVER		localhost
MYSQL_USERNAME		mail
MYSQL_PASSWORD		passwd
MYSQL_PORT		0
MYSQL_OPT		0
MYSQL_DATABASE		postfix
MYSQL_USER_TABLE	users
MYSQL_CRYPT_PWFIELD	crypt
MYSQL_UID_FIELD		uid
MYSQL_GID_FIELD		gid
MYSQL_LOGIN_FIELD	id
MYSQL_HOME_FIELD	home
MYSQL_NAME_FIELD	name
MYSQL_MAILDIR_FIELD	concat(home,'/',maildir)
MYSQL_WHERE_CLAUSE enabled=1

iptables

配置本地防火墙:

# iptables -A INPUT -p tcp -m multiport --dport 25,143 -j ACCEPT

测试:第1部分

确保所有服务都重新启动,以防万一。

# /etc/init.d/mysql restart
# /etc/init.d/postfix restart
# /etc/init.d/courier-authdaemon restart
# /etc/init.d/courier-imap restart
# /etc/init.d/courier-imap-ssl restart

确保Postfix,CourierIMAP和MySQL服务正在运行

# netstat -nltp | egrep '25|143|3306'
tcp   0   0 127.0.0.1:3306    0.0.0.0:*    LISTEN      10970/mysqld    
tcp   0   0 0.0.0.0:143       0.0.0.0:*    LISTEN      13872/couriertcpd
tcp   0   0 0.0.0.0:25        0.0.0.0:*    LISTEN      13116/master

确保设置了MX记录

$dig MX +short igi.test
10 mx1.igi.test.
$dig A +short mx1.igi.test
54.X.Y.Z

确保防火墙允许访问

$nmap -Pn -p T:25,143 mx1.igi.test | grep open
25/tcp  open  smtp
143/tcp open  imap

使用Telnet检查Postfix是否可以接收电子邮件

$telnet igi.test 25
Trying 54.X.Y.Z..
Connected to igi.test.
220 *
EHLO igi.test
250-igi.test
250-PIPELINING
250-SIZE 10240000
250-ETRN
250-XXXXXXXA
250-ENHANCEDSTATUSCODES
250-8BITMIME
250 DSN
MAIL FROM: Hyman@theitroad
250 2.1.0 Ok
RCPT TO: Hyman@theitroad
250 2.1.5 Ok
data
354 End data with .
this is a tets email
to check postfix installation from telnet
.
250 2.0.0 Ok: queued as 85E663061
quit
221 2.0.0 Bye
Connection closed by foreign host.

在服务器上检查新收到的电子邮件:

# ls -l /var/spool/mail/virtual/igi/new/
total 4
-rw------- 1 virtual virtual 338 Dec  1 15:39 1417448343.Vca01I310fM579863.igi.test

如果以上操作失败,请检查日志:

# tail /var/log/mail.log 
# tail /var/log/mysql/mysql.log

通过IMAP检索电子邮件

我们在这里使用Icedove(在Debian上也称为Thunderbird)。
以下是mail.log的简短摘录,显示了当我们连接Icedove时会发生的情况:

imapd: Connection, ip=[::ffff:1.2.3.X]
authdaemond: received auth request, service=imap, authtype=login
authdaemond: authmysql: trying this module
authdaemond: authmysqllib: connected. Versions: header 50524, client 50540, server 50540
authdaemond: SQL query: SELECT id, crypt, "", uid, gid, home, concat(home,'/',maildir), "", name, "" FROM users WHERE id = 'Hyman@theitroad'  AND (enabled=1)
authdaemond: password matches successfully
authdaemond: authmysql: sysusername=, sysuserid=5000, sysgroupid=5000, homedir=/var/spool/mail/virtual, Hyman@theitroad, fullname=igi, maildir=/var/spool/mail/virtual/igi/, quota=, options=
authdaemond: authmysql: clearpasswd=, passwd=b10ed288afd8f90LLQe7/TKgrDbLcQlb8V11NTs28bDGPCU.KoVOWYuz7
authdaemond: Authenticated: sysusername=, sysuserid=5000, sysgroupid=5000, homedir=/var/spool/mail/virtual, Hyman@theitroad, fullname=igi, maildir=/var/spool/mail/virtual/igi/, quota=, options=
authdaemond: Authenticated: clearpasswd=passwd, passwd=b10ed288afd8f90LLQe7/TKgrDbLcQlb8V11NTs28bDGPCU.KoVOWYuz7
imapd: LOGIN, Hyman@theitroad, ip=[::ffff:1.2.3.X], port=[17181], protocol=IMAP

从本地主机发送测试电子邮件

$echo "Test" | mail -v -s "Test from Postfix " Hyman@theitroad

安全SMTP

SASL

安装SASL:

# apt-get install libsasl2-modules libsasl2-modules-sql libgsasl7 \
libauthen-sasl-cyrus-perl sasl2-bin libpam-mysql

启用Postfix来访问SASL文件:

# adduser postfix sasl
# mkdir -p /var/spool/postfix/var/run/saslauthd

将以下内容添加到'/etc/postfix/main.cf'中:

smtpd_sasl_auth_enable = yes
broken_sasl_auth_clients = no
smtpd_sasl_security_options = noanonymous
smtpd_sasl_local_domain =
# Add permit_sasl_authenticated to you existing  smtpd_sender_restrictions
# Add permit_sasl_authenticated to you existing  smtpd_recipient_restrictions

这是“/etc/default/saslauthd”文件的样子:

# grep -ve "^#" -ve "^$" /etc/default/saslauthd
START=yes
DESC="SASL Authentication Daemon"
NAME="saslauthd"
MECHANISMS="pam"
MECH_OPTIONS=""
THREADS=5
OPTIONS="-r -c -m /var/spool/postfix/var/run/saslauthd"

告诉Postfix如何与SASL进行交互:

# cat > /etc/postfix/sasl/smtpd.conf << EOL
pwcheck_method: saslauthd
mech_list: plain login cram-md5 digest-md5
log_level: 7
allow_plaintext: true
auxprop_plugin: sql
sql_engine: mysql
sql_hostnames: 127.0.0.1
sql_user: mail
sql_passwd: passwd
sql_database: postfix
sql_select: select crypt from users where id='%Hyman@theitroad%r' and enabled = 1
EOL

告诉PAM如何通过MySQL验证SMTP:

# cat > /etc/pam.d/smtp << EOL
auth required pam_mysql.so user=mail passwd=passwd host=127.0.0.1 db=postfix table=users usercolumn=id passwdcolumn=crypt crypt=1
account sufficient pam_mysql.so user=mail passwd=passwd host=127.0.0.1 db=postfix table=users usercolumn=id passwdcolumn=crypt crypt=1
EOL

重新启动服务:

# /etc/init.d/saslauthd restart
# /etc/init.d/postfix restart

TLS:postfix

创建一个SSL证书:

$cd /etc/postfix
$openssl req -new -outform PEM -out postfix.cert -newkey rsa:2048 -nodes \
-keyout postfix.key -keyform PEM -days 1825 -x509

将以下行添加到'/etc/postfix/main.cf'中。

smtp_tls_security_level = may
smtpd_tls_security_level = may
smtp_tls_note_starttls_offer = yes
smtpd_tls_loglevel = 1
smtpd_tls_received_header = yes
smtpd_tls_session_cache_timeout = 3600s
tls_random_source = dev:/dev/urandom
smtpd_tls_cert_file=/etc/postfix/postfix.cert
smtpd_tls_key_file=/etc/postfix/postfix.key
# smtpd_tls_session_cache_database = btree:${data_directory}/smtpd_scache
# smtp_tls_session_cache_database = btree:${data_directory}/smtp_scache

这是“ /etc/postfix/main.cf”文件的样子:

# grep -ve "^#" -ve "^$" /etc/postfix/main.cf
myorigin = /etc/mailname
smtpd_banner = $myorigin ESMTP $mail_name
biff = no
relayhost = 
inet_interfaces = all
mynetworks_style = host
inet_protocols = ipv4
append_dot_mydomain = no
delay_warning_time = 4h
readme_directory = no
smtp_tls_security_level = may
smtpd_tls_security_level = may
smtp_tls_note_starttls_offer = yes
smtpd_tls_loglevel = 1
smtpd_tls_received_header = yes
smtpd_tls_session_cache_timeout = 3600s
tls_random_source = dev:/dev/urandom
smtpd_tls_cert_file=/etc/postfix/postfix.cert
smtpd_tls_key_file=/etc/postfix/postfix.key
alias_maps = hash:/etc/postfix/aliases
alias_database = hash:/etc/postfix/aliases
virtual_mailbox_base = /var/spool/mail/virtual
virtual_mailbox_maps = mysql:/etc/postfix/mysql_mailbox.cf
virtual_alias_maps = mysql:/etc/postfix/mysql_alias.cf
virtual_mailbox_domains = mysql:/etc/postfix/mysql_domains.cf
virtual_uid_maps = static:5000
virtual_gid_maps = static:5000
local_recipient_maps =
mydestination =
mynetworks = 127.0.0.0/8 [::ffff:127.0.0.0]/104 [::1]/128
message_size_limit = 2097152
mailbox_size_limit = 1073741824
recipient_delimiter = +
unknown_local_recipient_reject_code = 450
maximal_queue_lifetime = 7d
minimal_backoff_time = 1000s
maximal_backoff_time = 8000s
smtp_helo_timeout = 60s
smtpd_recipient_limit = 10
smtpd_soft_error_limit = 3
smtpd_hard_error_limit = 12
smtpd_helo_restrictions = permit_mynetworks, 
 warn_if_reject,
 reject_non_fqdn_hostname,
 reject_invalid_hostname,
 permit
smtpd_sender_restrictions = permit_mynetworks,
 permit_sasl_authenticated,
 warn_if_reject,
 reject_non_fqdn_sender,
 reject_unknown_sender_domain,
 reject_unauth_pipelining,
 permit
smtpd_client_restrictions = reject_rbl_client sbl.spamhaus.org, 
 reject_rbl_client blackholes.easynet.nl
smtpd_recipient_restrictions = reject_unauth_pipelining,
 permit_mynetworks,
 permit_sasl_authenticated,
 reject_non_fqdn_recipient,
 reject_unknown_recipient_domain,
 reject_unauth_destination,
 reject_rbl_client sbl.spamhaus.org,
 permit
smtpd_data_restrictions = reject_unauth_pipelining
smtpd_helo_required = yes
smtpd_delay_reject = yes
disable_vrfy_command = yes
smtpd_sasl_auth_enable = yes
broken_sasl_auth_clients = no
smtpd_sasl_security_options = noanonymous
smtpd_sasl_local_domain =

这是“ /etc/postfix/master.cf”文件的样子:

# grep -ve "^#" -ve "^$"  /etc/postfix/master.cf
smtp      inet  n       -       -       -       -       smtpd
submission inet n       -       n       -       -       smtpd 
 -o smtpd_sasl_auth_enable=yes 
 -o smtpd_tls_auth_only=yes
 -o smtpd_client_restrictions=permit_sasl_authenticated,reject_unauth_destination,reject
 -o smtpd_sasl_security_options=noanonymous,noplaintext
 -o smtpd_sasl_tls_security_options=noanonymous
smtps     inet  n       -       n       -       -       smtpd 
 -o smtpd_tls_wrappermode=yes 
 -o smtpd_sasl_auth_enable=yes
 -o smtpd_tls_auth_only=yes
 -o smtpd_client_restrictions=permit_sasl_authenticated,reject
 -o smtpd_sasl_security_options=noanonymous,noplaintext
 -o smtpd_sasl_tls_security_options=noanonymous
pickup    unix  n       -       -       60      1       pickup
cleanup   unix  n       -       -       -       0       cleanup
qmgr      unix  n       -       n       300     1       qmgr
tlsmgr    unix  -       -       -       1000?   1       tlsmgr
rewrite   unix  -       -       -       -       -       trivial-rewrite
bounce    unix  -       -       -       -       0       bounce
defer     unix  -       -       -       -       0       bounce
trace     unix  -       -       -       -       0       bounce
verify    unix  -       -       -       -       1       verify
flush     unix  n       -       -       1000?   0       flush
proxymap  unix  -       -       n       -       -       proxymap
proxywrite unix -       -       n       -       1       proxymap
smtp      unix  -       -       -       -       -       smtp
relay     unix  -       -       -       -       -       smtp
showq     unix  n       -       -       -       -       showq
error     unix  -       -       -       -       -       error
retry     unix  -       -       -       -       -       error
discard   unix  -       -       -       -       -       discard
local     unix  -       n       n       -       -       local
virtual   unix  -       n       n       -       -       virtual
lmtp      unix  -       -       -       -       -       lmtp
anvil     unix  -       -       -       -       1       anvil
scache    unix  -       -       -       -       1       scache
maildrop  unix  -       n       n       -       -       pipe
  flags=DRhu user=vmail argv=/usr/bin/maildrop -d ${recipient}
uucp      unix  -       n       n       -       -       pipe
  flags=Fqhu user=uucp argv=uux -r -n -z -a$sender - $nexthop!rmail ($recipient)
ifmail    unix  -       n       n       -       -       pipe
  flags=F user=ftn argv=/usr/lib/ifmail/ifmail -r $nexthop ($recipient)
bsmtp     unix  -       n       n       -       -       pipe
  flags=Fq. user=bsmtp argv=/usr/lib/bsmtp/bsmtp -t$nexthop -f$sender $recipient
scalemail-backend unix	-	n	n	-	2	pipe
  flags=R user=scalemail argv=/usr/lib/scalemail/bin/scalemail-store ${nexthop} ${user} ${extension}
mailman   unix  -       n       n       -       -       pipe
  flags=FR user=list argv=/usr/lib/mailman/bin/postfix-to-mailman.py
  ${nexthop} ${user}

重新启动后缀:

# service postfix restart

TLS:Courier IMAP

创建一个SSL证书:

# cd /etc/courier
$openssl req -x509 -newkey rsa:2048 -keyout imapd.pem \
-out imapd.pem -nodes -days 1825

这是“/etc/courier/imapd-ssl”的样子:

# grep -ve "^#" -ve "^$" /etc/courier/imapd-ssl
SSLPORT=993
SSLADDRESS=0.0.0.0
SSLPIDFILE=/var/run/courier/imapd-ssl.pid
SSLLOGGEROPTS="-name=imapd-ssl"
IMAPDSSLSTART=YES
IMAPDSTARTTLS=YES
IMAP_TLS_REQUIRED=1
COURIERTLS=/usr/bin/couriertls
TLS_KX_LIST=ALL
TLS_COMPRESSION=ALL
TLS_CERTS=X509
TLS_CERTFILE=/etc/courier/imapd.pem
TLS_TRUSTCERTS=/etc/ssl/certs
TLS_VERIFYPEER=NONE
TLS_CACHEFILE=/var/lib/courier/couriersslcache
TLS_CACHESIZE=524288
MAILDIRPATH=Maildir

重新启动服务:

# service courier-imap-ssl restart

iptables

配置本地防火墙以允许通过加密通道:

# iptables -A INPUT -p tcp -m multiport --dport 587,465,993 -j ACCEPT

测试:第2部分

# /etc/init.d/mysql restart
# /etc/init.d/postfix restart
# /etc/init.d/courier-authdaemon restart
# /etc/init.d/courier-imap restart
# /etc/init.d/courier-imap-ssl restart
# /etc/init.d/saslauthd restart
# netstat -nltp | egrep '25|587|465|143|993|3306'
tcp   0   0 127.0.0.1:3306  0.0.0.0:*     LISTEN    18177/mysqld    
tcp   0   0 0.0.0.0:587     0.0.0.0:*     LISTEN    20534/master    
tcp   0   0 0.0.0.0:143     0.0.0.0:*     LISTEN    17434/couriertcpd
tcp   0   0 0.0.0.0:465     0.0.0.0:*     LISTEN    20534/master    
tcp   0   0 0.0.0.0:25      0.0.0.0:*     LISTEN    20534/master    
tcp   0   0 0.0.0.0:993     0.0.0.0:*     LISTEN    20710/couriertcpd
# nmap -Pn -p T:25,143,587,465,993 mx1.igi.test | grep open
25/tcp  open  smtp
143/tcp open  imap
465/tcp open  smtps
587/tcp open  submission
993/tcp open  imaps

可能会派上用场的外部工具:

  • http://mxtoolbox.com/SuperTool.aspx
  • http://www.checktls.com/perl/TestReceiver.pl

当一切(最终)工作时

禁用“ /etc/mysql/my.cnf”登录并重启MySQL服务:

# service mysql restart

禁用“/etc/courier/authdaemonrc”登录并重新启动服务:

# service courier-authdaemon restart

故障排除

如果我们在'/var/log/mail.log'中看到此内容:

postfix/smtpd[10104]: warning: SASL authentication failure: cannot connect to saslauthd server: No such file or directory

我们可能需要执行以下操作:

# rm /var/run/saslauthd/-rf
# ln -sf /var/spool/postfix/var/run/saslauthd /var/run
# /etc/init.d/saslauthd restart

ThunderBird电子邮件客户端设置

IMAPS:

  • 服务器名称:mail.igi.test
  • 端口:993
  • 连接安全性:SSL/TLS
  • 验证方式:普通密码

(SMTPS):

  • 服务器名称:mail.igi.test
  • 端口:465
  • 连接安全性:SSL/TLS
  • 验证方法:普通密码