创建smtpd.conf,并且内容如下:
pwcheck_method:saslauthd
mech_list:plain login
allow_plaintext: true
auxprop_plugin: mysql
sql_hostnames: 127.0.0.1
sql_user: extmail
sql_password: extmail
sql_database: extmail
log_level:7
sql_select: SELECT password FROM mailbox WHERE username=’%u@%r’ and domain=’%r’
4).更改main.cf 文件
vi /etc/postfix/main.cf
###########SMTP AUTH config###############
broken_sasl_auth_clients = yes
smtpd_sasl_auth_enable = yes
smtpd_sasl_local_domain = $myhostname
smtpd_sasl_security_options = noanonymous
###########smtpd related config############
smtpd_recipient_restrictions = permit_mynetworks, permit_sasl_authenticated, reject_sender_login_mismatch, reject_unknown_sender_domain, reject_non_fqdn_hostname, reject_non_fqdn_sender, reject_non_fqdn_recipient, reject_unknown_recipient_domain, reject_unauth_destination, reject_unauth_pipelining, reject_invalid_hostname, check_recipient_maps
5).添加用户
adduser postfix sasl
6).重启postfix saslauthd
/etc/init.d/postfix restart
/etc/init.d/saslauthd restart
7).测验
telnet localhost 25
Trying 127.0.0.1…
Connected to localhost.
Escape character is ‘^]’.
220 mail.extmail.org ESMTP Postfix
ehlo localhost
250-mail.extmail.org
250-PIPELINING
250-SIZE 102400000
250-VRFY
250-ETRN
250-STARTTLS
250-AUTH PLAIN LOGIN
250-AUTH=PLAIN LOGIN
250-ENHANCEDSTATUSCODES
250-8BITMIME
250 DSN
auth login
334 VXNlcm5hbWU6
cG9zdG1hc3RlckBleHRtYWlsLm9yZw==
334 UGFzc3dvcmQ6
ZXh0bWFpbA==
235 2.7.0 Authentication successful
quit
221 2.0.0 Bye
Connection closed by foreign host.
如果出现Authentication successful 表示没有问题了
16.POP验证
vi /etc/courier/authdaemonrc
#更改如下一项
authmodulelist="authmysql"
cp /etc/courier/authmysqlrc /etc/courier/authmysqlrc_orig
cat /dev/null > /etc/courier/authmysqlrc
vi /etc/courier/authmysqlrc
#内容如下:
MYSQL_SERVER localhost
MYSQL_USERNAME extmail
MYSQL_PASSWORD extmail
MYSQL_SOCKET /var/run/mysqld/mysqld.sock
MYSQL_PORT 3306
MYSQL_OPT 0
MYSQL_DATABASE extmail
MYSQL_USER_TABLE mailbox
MYSQL_CRYPT_PWFIELD password
MYSQL_UID_FIELD uidnumber
MYSQL_GID_FIELD gidnumber
MYSQL_LOGIN_FIELD username
MYSQL_HOME_FIELD homedir
MYSQL_NAME_FIELD name
MYSQL_MAILDIR_FIELD maildir
MYSQL_QUOTA_FIELD quota
MYSQL_SELECT_CLAUSE SELECT username,password,"",uidnumber,gidnumber,\
CONCAT(‘/home/vmail/’,homedir), \
CONCAT(‘/home/vmail/’,maildir), \
quota, \
name, \
CONCAT("disablesmtpd=",disablesmtpd, \
",disablesmtp=",disablesmtp, \
",disablewebmail=",disablewebmail, \
",disablenetdisk=",disablenetdisk, \
",disableimap=",disableimap, \
",disablepop3=",disablepop3, \
",netdiskquota=",netdiskquota) \
FROM mailbox \
WHERE username = ‘$(local_part)@$(domain)’
配置Courier-POP3
vi /etc/courier/pop3d
MAILDIRPATH=/home/vmail/
配置Courier-IMAP
vi /etc/courier/imapd
MAILDIRPATH=/home/vmail/