1) $ vim /etc/postfix/main.cf

 

##############SASL####################

smtpd_sasl_auth_enable = yes

smtpd_sasl2_auth_enable = yes

smtpd_sasl_security_options = noanonymous

broken_sasl_auth_clients = yes

smtpd_recipient_restrictions =

    permit_mynetworks,

    permit_sasl_authenticated,

    reject_unknown_sender_domain,

    reject_non_fqdn_sender,

    reject_non_fqdn_recipient,

    reject_unknown_recipient_domain,

    reject_unauth_pipelining,

    reject_unauth_destination,

permit

 

#黑体为要做的配置

#列出本地用户的列表,以便验证 From: 本地域 To: 本地域

smtpd_sender_login_maps =

 mysql:/etc/postfix/mysql_virtual_sender_maps.cf,

 mysql:/etc/postfix/mysql_virtual_alias_maps.cf

 

smtpd_reject_unlisted_sender = yes

 

#本地域向本地域发信也需要SMTP身份验证

smtpd_sender_restrictions =

    reject_sender_login_mismatch,

    reject_authenticated_sender_login_mismatch,

    reject_unauthenticated_sender_login_mismatch

 

2)$ vim /etc/postfix/mysql_virtual_sender_maps.cf

user = extmail

password = extmail

hosts = localhost

dbname = extmail

table = mailbox

select_field = username

where_field = username

additional_conditions = AND active = 1