Tuesday, April 26, 2016

email - Postfix alias only forwarding to local users



I have set up Dovecot and Postfix using this tutorial, which works for receiving and sending mail. The aliases also work fine, although only for local users. I.e. I can make a forward from noaddress@mydomain.com to realaddress@mydomain.com, where only realaddress is defined as a virtual user (using MySQL). What I want to do is forward to an external address, such as Gmail or another mailserver. All my config-files are exactly as stated in the link above.
I've tried adding





virtual_alias_domains =




to postfix/main.cf, but that didn't solve anything.



Also manually adding the domains there, i.e.




virtual_alias_domains = forwarddomain.com





didn't work. The error I get is




to=, orig_to=,
relay=mydomain.com[private/dovecot-lmtp], delay=0.07,
delays=0.05/0.01/0/0.01, dsn=5.1.1, status=bounced (host
mydomain.com[private/dovecot-lmtp] said: 550 5.1.1
User doesn't exist:
contact@forwarddomain.com (in reply to RCPT TO command))
.





Output of postconf -n:




alias_database = hash:/etc/aliases
alias_maps = hash:/etc/aliases
append_dot_mydomain = no
biff = no
config_directory = /etc/postfix

content_filter = scan:127.0.0.1:10026
inet_interfaces = all
mailbox_size_limit = 0
mydestination = localhost
myhostname = mydomain.com
mynetworks = 127.0.0.0/8 [::ffff:127.0.0.0]/104 [::1]/128
myorigin = /etc/mailname
readme_directory = no
receive_override_options = no_address_mappings
recipient_delimiter = +

relayhost =
smtp_tls_session_cache_database = btree:${data_directory}/smtp_scache
smtpd_banner = $myhostname ESMTP $mail_name (Ubuntu)
smtpd_recipient_restrictions = permit_sasl_authenticated, permit_mynetworks, reject_unauth_destination
smtpd_relay_restrictions = permit_mynetworks permit_sasl_authenticated defer_unauth_destination
smtpd_sasl_auth_enable = yes
smtpd_sasl_path = private/auth
smtpd_sasl_type = dovecot
smtpd_tls_auth_only = no
smtpd_tls_cert_file = /etc/ssl/certs/dovecot.pem

smtpd_tls_key_file = /etc/ssl/private/dovecot.pem
smtpd_use_tls = yes
virtual_alias_domains =
virtual_alias_maps = mysql:/etc/postfix/mysql-virtual-alias-maps.cf
virtual_mailbox_domains = mysql:/etc/postfix/mysql-virtual-mailbox-domains.cf
virtual_mailbox_maps = mysql:/etc/postfix/mysql-virtual-mailbox-maps.cf
virtual_transport = lmtp:unix:private/dovecot-lmtp

Answer



Finally found the answer, turned out postfix was trying to connect to gmail using ipv6. To fix this, configure ipv6 on the server, or like I did, disable ipv6 in /etc/postfix/main.cf by adding the following line:





inet_protocols = ipv4




and restarting postfix:




service postfix restart




No comments:

Post a Comment

linux - How to SSH to ec2 instance in VPC private subnet via NAT server

I have created a VPC in aws with a public subnet and a private subnet. The private subnet does not have direct access to external network. S...