Postfix email forwarding giving “relay access denied” for inbound mail to be forwarded

emailemail-serverpostfix

I'm running Postfix 2.6.6 on AMI Linux. The purpose of this Postfix server is to:

1) Send mail for client computers on the network.

2) Receive external email for email addresses of various usernames and domains, and forward those emails to another external email address. For example, unknown user sends an email to info@example.com and Postfix forwards it to bob@gmail.com.

#1 is working fine. However, whenever any external user sends an email to info@example.com, Postfix gives a "relay access denied" message.

Here is the log:

/var/log/maillog

Oct 15 18:53:21 mx postfix/smtpd[14196]: connect from mail-wm0-f51.google.com[74.125.82.51]
Oct 15 18:53:21 mx postfix/smtpd[14196]: NOQUEUE: reject: RCPT from mail-wm0-f51.google.com[74.125.82.51]: 554 5.7.1 <info@example.com>: Relay access denied; from=<externaluser@gmail.com> to=<info@example.com> proto=ESMTP helo=<mail-wm0-f51.google.com>
Oct 15 18:53:21 mx postfix/smtpd[14196]: disconnect from mail-wm0-f51.google.com[74.125.82.51]

Here are the settings in the configuration files:

postconf -n

alias_database = hash:/etc/mail/aliases
alias_maps = hash:/etc/mail/aliases
command_directory = /usr/sbin
config_directory = /etc/postfix
daemon_directory = /usr/libexec/postfix
data_directory = /var/lib/postfix
debug_peer_level = 2
html_directory = no
inet_interfaces = all
inet_protocols = all
local_header_rewrite_clients = permit_inet_interfaces permit_mynetworks
local_transport = error:local delivery is disabled
mail_owner = postfix
mailq_path = /usr/bin/mailq.postfix
manpage_directory = /usr/share/man
masquerade_domains = websrvcs.myowndomain.ca
milter_default_action = accept
milter_protocol = 6
mydestination = localhost
mynetworks = 127.0.0.0/8 [::1]/128 10.0.19.40/32
newaliases_path = /usr/bin/newaliases.postfix
non_smtpd_milters = $smtpd_milters
queue_directory = /var/spool/postfix
readme_directory = /usr/share/doc/postfix-2.6.6/README_FILES
sample_directory = /usr/share/doc/postfix-2.6.6/samples
sendmail_path = /usr/sbin/sendmail.postfix
setgid_group = postdrop
smtp_generic_maps = pgsql:/etc/postfix/pgsql-generic.cf
smtp_header_checks = regexp:/etc/postfix/smtp_header_checks
smtpd_helo_required = yes
smtpd_milters = inet:127.0.0.1:57320
smtpd_tls_CAfile = /etc/letsencrypt/live/mx.myowndomain.ca/chain.pem
smtpd_tls_cert_file = /etc/letsencrypt/live/mx.myowndomain.ca/cert.pem
smtpd_tls_key_file = /etc/letsencrypt/live/mx.myowndomain.ca/privkey.pem
smtpd_tls_security_level = may
unknown_local_recipient_reject_code = 550
virtual_alias_maps = hash:/etc/postfix/virtual

/etc/mail/aliases

postmaster: ec2-user
root: ec2-user

/etc/postfix/pgsql-generic.cf

hosts = pgsql.myowndomain.ca:theport
user = postfix
password = password
dbname = thedb
query = SELECT result FROM postfix.generic WHERE '%s' ~* pattern LIMIT 1;

/etc/postfix/smtp_header_checks

/^Received:/ IGNORE
/^Sender:/ IGNORE

/etc/postfix/virtual

info@example.com           bob@gmail.com
...other entries

I've spent a number of hours troubleshooting and searching for answers, but it seems that all the previous posts I can find deal with situations that are slightly different than mine. Now I'm at a loss.

Best Answer

Your postfix does not recognize that it should accept emails for example.com for delivery, it thinks that gmail is trying to use your email server as a relay.

Have a look at http://www.postfix.org/postconf.5.html#mydestination and add the domain name example.com to it.