I was looking at this answer to solve my issue but I see that I already set it.

The point is: I am running postfix to deliver mail using Gsuite. If I deliver mail to any other domain it works fine. If I send mail to an address @mydomain it will try to dispatch it internally. I want to force posftix to send it using Gsuite SMTP anyway.

The log shows:

Oct  6 17:44:42 mydomain postfix/pickup[277348]: 84DFB1E3E9: uid=33 from=<www-data>
Oct  6 17:44:42 mydomain postfix/cleanup[277442]: 84DFB1E3E9: message-id=<20201006154442.84DFB1E3E9@mydomain.com>
Oct  6 17:44:42 mydomain postfix/qmgr[2082]: 84DFB1E3E9: from=<www-data@mydomain.com>, size=451, nrcpt=1 (queue active)
Oct  6 17:44:42 mydomain postfix/local[277444]: 84DFB1E3E9: to=<admin@mydomain.com>, relay=local, delay=0.03, delays=0.02/0.01/0/0.01, dsn=5.1.1, status=bounced (unknown user: "admin")
Oct  6 17:44:42 mydomain postfix/cleanup[277442]: 8AD961E3EA: message-id=<20201006154442.8AD961E3EA@mydomain.com>
Oct  6 17:44:42 mydomain postfix/bounce[277445]: 84DFB1E3E9: sender non-delivery notification: 8AD961E3EA
Oct  6 17:44:42 mydomain postfix/qmgr[2082]: 8AD961E3EA: from=<>, size=2331, nrcpt=1 (queue active)
Oct  6 17:44:42 mydomain postfix/qmgr[2082]: 84DFB1E3E9: removed
Oct  6 17:44:42 mydomain postfix/local[277444]: 8AD961E3EA: to=<www-data@mydomain.com>, relay=local, delay=0.01, delays=0/0/0/0, dsn=2.0.0, status=sent (delivered to mailbox)
Oct  6 17:44:42 mydomain postfix/qmgr[2082]: 8AD961E3EA: removed

Note that admin is not an user defined on the server, so the mail is bounced. My hostname is mydomain.com

My postfix main.cf:

smtpd_banner = $myhostname ESMTP $mail_name (Ubuntu)
biff = no

append_dot_mydomain = no

# Uncomment the next line to generate "delayed mail" warnings
#delay_warning_time = 4h

readme_directory = no
compatibility_level = 2

# TLS parameters
smtpd_tls_session_cache_database = btree:${data_directory}/smtpd_scache
smtp_tls_session_cache_database = btree:${data_directory}/smtp_scache
smtp_tls_wrappermode =  yes

relayhost= [smtp-relay.gmail.com]:465
smtpd_relay_restrictions = permit_mynetworks permit_sasl_authenticated defer_unauth_destination
myhostname = thesmartred.com
alias_maps = hash:/etc/aliases
alias_database = hash:/etc/aliases
myorigin = /etc/mailname
mydestination = $myhostname, mydomain.com, localhost.mydomain.com, localhost
mynetworks = [::ffff:]/104 [::1]/128
mailbox_size_limit = 0
recipient_delimiter = +
inet_interfaces = all
inet_protocols = ipv4
# Enable SASL authentication
smtp_sasl_auth_enable = yes
# Disallow methods that allow anonymous authentication
smtp_sasl_security_options = noanonymous
# Location of sasl_passwd
smtp_sasl_password_maps = hash:/etc/postfix/sasl/sasl_passwd
# Enable STARTTLS encryption
smtp_tls_security_level = encrypt
# Location of CA certificates
smtp_tls_CAfile = /etc/ssl/certs/ca-certificates.crt

What am I doing wrong?

  • this doesn't work, it will cause a bunch of other errors in the log Oct 6, 2020 at 16:40

2 Answers 2


Actually I solved using the transport directive. I added to my main.cf the following:

transport_maps =  hash:/etc/postfix/transport 

Then I created the transport file using

*  smtp:[smtp-relay.gmail.com]:465

that will deliver all the email using gmail smtp (internal and external).

and then I run

postmap hash:/etc/postfix/transport

Finally I restarted postfix and everything is fixed.


You put your domain name in mydestination. This tells Postfix that it is meant to handle mail being sent to the domain, so it tries to deliver such mail locally.

For a mail server that is meant to relay everything, the naked domain name should not be in mydestination or in the file /etc/mailname. (A subdomain is fine.)

Further, the system hostname should never be set to the naked domain name, as this will also confuse Postfix.

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.