I use gmail to receive e-mails both from my gmail address and my own domain, but gmail no longer allows you to send e-mails from your own domain name unless you provide your own SMTP server to send via.
Therefore I am trying to configure Postfix on an Ubuntu server to relay e-mail from any remote device to the destination e-mail address on the e-mail. I only want the server to relay e-mails from mydomain (only if authenticated) and not retain any emails on the server in user mailboxes.
Currently I been able to relay e-mails from a particular source address, however e-mails that are send to a gmail address are bounced when relayed. If I use sendmail from the server itself, gmail does not bounce it proving that gmail is happy to receive e-mails from my server. But when e-mails are relayed I get the following message from gmail:
status=bounced (host gmail-smtp-in.l.google.com[2a00:1450:400c:c00::1a] said:
550-5.7.1 [2001:41d0:a:f9a0::1 12] Our system has detected that this
550-5.7.1 message is likely unsolicited mail.
To reduce the amount of spam sent 550-5.7.1 to Gmail, this message has been
blocked. Please visit 550-5.7.1
http://support.google.com/mail/bin/answer.py?hl=en&answer=188131 for 550 5.7.1 more information. n6si25532296wjy.39
- gsmtp (in reply to end of DATA command))
I also tried using header checks to strip all the headers that showed that the e-mail was from another client before it reached the server. But this didn't help.
Most of the information I find is about relaying all my e-mails through gmail which I don't want to do. I just the server to act as the final MTA that will send e-mails directly to the recipient's mailserver without being treated as spam.
My current postfix configuration:
# 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
smtpd_banner = $myhostname ESMTP $mail_name (Ubuntu)
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
# TLS parameters
smtpd_tls_cert_file=/etc/ssl/certs/ssl-cert-snakeoil.pem
smtpd_tls_key_file=/etc/ssl/private/ssl-cert-snakeoil.key
smtpd_use_tls=yes
smtpd_tls_session_cache_database = btree:${data_directory}/smtpd_scache
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.
smtpd_relay_restrictions = permit_mynetworks permit_sasl_authenticated defer_unauth_destination
myhostname = {@mydomain.com}
alias_maps = hash:/etc/aliases
alias_database = hash:/etc/aliases
myorigin = /etc/mailname
mydestination = {@mydomain.com}, {server_hostname}, localhost
relayhost =
mynetworks = {my_ip_address} 127.0.0.0/8 [::ffff:127.0.0.0]/104 [::1]/128
mailbox_size_limit = 0
recipient_delimiter = +
inet_interfaces = all
# Strip received from headers to hide original remote client address
mime_header_checks = regexp:/etc/postfix/header_checks
header_checks = regexp:/etc/postfix/header_checks
smtp_header_checks = regexp:/etc/postfix/header_checks