Postfix 虚拟域:如何将电子邮件发送到具有每个虚拟收件人对应虚拟域的本地或非目的地?

Postfix 虚拟域:如何将电子邮件发送到具有每个虚拟收件人对应虚拟域的本地或非目的地?

我需要帮助将服务器中的后缀配置为多个虚拟域和子域的收件人和发件人。我希望从此服务器的任何本地收件人发送的每封电子邮件都能通过其自己的虚拟域到达目的地,无论它是否是本地投递。

我已将 main.cf 设置为在其自己的虚拟主目录中接收每封电子邮件(“virtual_user@virtual_domain”);到目前为止,一切正常。但是,当我尝试从此服务器的任何收件人向本地或外部收件人发送电子邮件时,电子邮件将使用此服务器的主机名作为其域(“virtual_user@hostname”)。

服务器:Linux姓名3.16.0-4-amd64 #1 SMP Debian 3.16.7-ckt11-1 (2015-05-24) x86_64 GNU/Linux

Postfix 2.11.3-1

名称.域名是服务器的 FQDN。

这是我的 main.cf

# See /usr/share/postfix/main.cf.dist for a commented, more complete version
# Debian specific:  Specifying a file name will cause the first
# line of that file to be used as the name.  The Debian default
# is /etc/mailname.
#myorigin = /etc/mailname # **line 1: "name.domain"**
smtpd_banner = $myhostname ESMTP $mail_name (Debian/GNU)
biff = no
# appending .domain is the MUA's job.
append_dot_mydomain = no
# Uncomment the next line to generate "delayed mail" warnings
#delay_warning_time = 4h
readme_directory = no
home_mailbox = Maildir/
#mailbox_command = procmail -a "$EXTENSION"
virtual_mailbox_domains = /etc/postfix/vhosts # **line 1: "domain" & line 2: "other.domain"**
virtual_mailbox_base = /home
virtual_mailbox_maps = hash:/etc/postfix/vmailbox # **line 1: "user1@domain domain/user1/Maildir/" & line 2: "[email protected] other.domain/user2/Maildir/"**
virtual_minimum_uid = 2000
virtual_uid_maps = hash:/etc/postfix/vuid # **line 1: "user1@domain 2001" & line 2: "[email protected] 2002"**
virtual_gid_maps = $virtual_uid_maps
virtual_alias_maps = hash:/etc/postfix/valias # **line 1: "user1@domain user1" & line 2: "[email protected] user2"**
#virtual_alias_domains =
# TLS parameters (server mode)
smtpd_tls_cert_file = /etc/dovecot/private/name.pem
smtpd_tls_key_file = /etc/dovecot/private/name.pem
smtpd_tls_CAfile = /etc/dovecot/private/name.pem
#smtpd_tls_cert_file = /etc/ssl/certs/ssl-cert-snakeoil.pem
#smtpd_tls_key_file = /etc/ssl/private/ssl-cert-snakeoil.key
#smtpd_tls_CAfile = /etc/postfix/certs/new-ca.crt
smtpd_use_tls = yes
smtpd_tls_session_cache_database = btree:${data_directory}/smtpd_scache
smtpd_tls_loglevel = 1
smtpd_tls_received_header = yes
# TLS to encrypt the connection to relay host (client mode)
smtp_use_tls = yes
smtp_tls_loglevel = 1
smtp_tls_note_starttls_offer = yes
smtp_tls_CApath = /etc/ssl/certs/
#smtp_tls_security_level = secure
tls_random_source = dev:/dev/urandom
smtp_tls_session_cache_database = btree:${data_directory}/smtp_scache
# See /usr/share/doc/postfix/TLS_README.gz in the postfix-doc package for
# information on enabling SSL in the smtp client.
# SMTP-SASL-AUTH (server mode)
smtpd_sasl_auth_enable = yes
#smtpd_sasl_application_name = smtpd
smtpd_sasl_local_domain = $myhostname
smtpd_sasl_security_options = noanonymous
broken_sasl_auth_clients = yes
smtpd_sasl_authenticated_header = yes
# SMTP-SASL-AUTH (client mode)
#smtp_sasl_auth_enable = yes
# auth -- credentials to authenticate yourself to relay hosts
#smtp_sasl_password_maps = hash:/etc/postfix/sasl_passwd
#smtp_sender_dependent_authentication = yes
#sender_dependent_relayhost_maps = hash:/etc/postfix/sender_relay
#smtp_sasl_security_options = noanonymous
#smtp_sasl_tls_security_options = noanonymous
#sasl auth with dovecot
#smtpd_sasl_type = dovecot
#smtpd_sasl_path = private/auth
smtpd_relay_restrictions = permit_mynetworks permit_sasl_authenticated defer_unauth_destination
smtpd_recipient_restrictions = permit_mynetworks, permit_sasl_authenticated, reject_unauth_destination
smtpd_client_restrictions = check_client_access hash:/etc/postfix/access
smtpd_sender_restrictions = check_sender_access hash:/etc/postfix/access
myhostname = name.domain
alias_maps = hash:/etc/aliases
alias_database = hash:/etc/aliases
**mydestination = $myhostname, localhost # ????**
mynetworks = 127.0.0.0/8 [::ffff:127.0.0.0]/104 [::1]/128
#relayhost =
**transport_maps = hash:/etc/postfix/transport # ????**
**default_transport = smtp # ????**
#local_transport = local:$myhostname
**local_transport = local:$virtual_mailbox_domains # ????**
message_size_limit = 2048000
mailbox_size_limit = 100000000
virtual_mailbox_limit = $mailbox_size_limit
smtpd_recipient_limit = 150
smtpd_recipient_overshoot_limit = 300
smtpd_client_connection_rate_limit = 60
smtpd_client_message_rate_limit = 60
smtpd_client_recipient_rate_limit = 300
smtpd_client_new_tls_session_rate_limit = 60
smtpd_client_event_limit_exceptions = no
recipient_delimiter = +
#inet_interfaces = all
inet_protocols = ipv4
# alias to map internal to external
**#smtp_generic_maps = hash:/etc/postfix/generic # does not resolve the local delivery**

# header checks
#header_checks = pcre:/etc/postfix/header_checks
#mime_header_checks = pcre:/etc/postfix/header_checks
#nested_header_checks = pcre:/etc/postfix/header_checks
# smtp header checks
#smtp_header_checks = pcre:/etc/postfix/header_checks
#smtp_mime_header_checks = pcre:/etc/postfix/header_checks
#smtp_nested_header_checks = pcre:/etc/postfix/header_checks

答案1

main.cf

canonical_maps = hash:/etc/postfix/canonical

然后在/etc/postfix/canonical

user1    user1@domain
user2    [email protected]

相关内容