1

I'm trying to create a setup where emails sent to certain addresses of my domain are forwarded to my Gmail and the rest gets deleted. So far i've been fiddling around with postfix settings, but none of the methods delivered messages to my inbox.

My first approach was with header_checks in /etc/postfix/main.cf like this: header_checks = regexp:/etc/postfix/header_checks and then in /etc/postfix/header_checks the following: /^To: test@mydomain.com/ REDIRECT mygmail@gmail.com. This didn't deliver any mails (not even in spam).

Then i tried it with forwards in /etc/postfix/main.cf like this: virtual_alias_domains = mydomain.com virtual_alias_maps = hash:/etc/postfix/virtual and then in /etc/postfix/virtual: test@mydomain.com mygmail@gmail.com. Again, i don't receive any emails in my Gmail (not in spam either).

I've created a filter in Gmail that all mail to (and from) @mydomain.com never go to spam and my MX record points to the IP address of my server.

Am i missing something (obvious)?

The output of postfix -n is:

alias_database = hash:/etc/aliases
alias_maps = hash:/etc/aliases
append_dot_mydomain = no
biff = no
config_directory = /etc/postfix
header_checks = regexp:/etc/postfix/header_checks
inet_interfaces = all
mailbox_size_limit = 0
milter_default_action = accept
milter_protocol = 2
mydestination = mail.mydomain.com, mydomain.com, myotherdomain.com
myhostname = mydomain.com
mynetworks = 127.0.0.0/8 [::ffff:127.0.0.0]/104 [::1]/128
myorigin = /etc/mailname
non_smtpd_milters = inet:localhost:12301
readme_directory = no
recipient_delimiter = +
relayhost =
smtp_generic_maps = hash:/etc/postfix/generic
smtp_tls_session_cache_database = btree:${data_directory}/smtp_scache
smtpd_banner = $myhostname ESMTP $mail_name (Debian/GNU)
smtpd_milters = inet:localhost:12301
smtpd_relay_restrictions = permit_mynetworks permit_sasl_authenticated defer_unauth_destination
smtpd_tls_cert_file = /etc/ssl/certs/ssl-cert-snakeoil.pem
smtpd_tls_key_file = /etc/ssl/private/ssl-cert-snakeoil.key
smtpd_tls_session_cache_database = btree:${data_directory}/smtpd_scache
smtpd_use_tls = yes
virtual_alias_domains = mydomain.com myotherdomain.com
virtual_alias_maps = hash:/etc/postfix/virtual

SOLVED!

The log files showed my that the Gmail server were unreachable. A little search on the internet showed me that Postfix is trying to connect to the Google SMTP via IPv6. My VPS doesn't support ipv6 so i had to add the option inet_protocols = ipv4 to /etc/postfix/main.conf

For future reference, below the rows in my log files (after sending an email)

Oct 12 06:25:05 vps241835 postfix/pickup[22448]: 2E2671E297: uid=0 from=<root>
Oct 12 06:25:05 vps241835 postfix/cleanup[22870]: 2E2671E297: message-id=<20161012042505.2E2671E297@mydomain.com>
Oct 12 06:25:05 vps241835 opendkim[374]: 2E2671E297: DKIM-Signature field added (s=mail, d=myotherdomain.nl)
Oct 12 06:25:05 vps241835 postfix/qmgr[17926]: 2E2671E297: from=<root@myotherdomain.nl>, size=31986, nrcpt=1 (queue active)
Oct 12 06:25:05 vps241835 postfix/smtp[22884]: connect to gmail-smtp-in.l.google.com[2a00:1450:400c:c04::1b]:25: Network is unreachable
Oct 12 06:25:05 vps241835 postfix/smtp[22884]: 2E2671E297: to=<mygmail@gmail.com>, relay=gmail-smtp-in.l.google.com[74.125.206.26]:25, delay=1.7, delays=1.2/0.01/0.21/0.27, dsn=2.0.0, status=sent (250 2.0.0 OK 1476246326 o4si8145221wjd.164 - gsmtp)
Oct 12 06:25:05 vps241835 postfix/qmgr[17926]: 2E2671E297: removed
0

The log files pointed me in the right direction. The log files showed my that the Gmail server was unreachable. A little search on the internet showed me that Postfix is trying to connect to the Google SMTP via IPv6. My VPS doesn't support ipv6 so i had to add the option inet_protocols = ipv4 in /etc/postfix/main.conf

| improve this answer | |
  • Remember to complain to the VPS provider about the lack of IPv6 support, and/or move to some other provider. – Michael Hampton Oct 12 '16 at 18:04

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.