问题原文
原帖链接 · konqi · CC BY-SA 3.0
What are the steps to set up postfix as SMTP relay that uses the Google Apps SMTP relay. There are a bunch of tutorials on the web that explain how to use the smtp.gmail.com gateway with SASL authentication but I could not find a working configuration for the Google Apps relay smtp-relay.google.com as described here, especially one that is specific to Google Compute.
I have setup the smtp relay service with 'Only addresses in my domains' as described here and verified that the IP is in fact the one I connect from.
I know that Google compute does not allow Port 25 as outgoing port as described here.
I am using debian linux or a debian derivative.
I have setup postfix as detailed in the docs but all i get in the mail.log is:
postfix/smtp[720]: send attr reason = host smtp-relay.gmail.com[66.102.1.28] said:
550-5.7.1 Invalid credentials for relay [104.155.78.1]. The IP address you've
550-5.7.1 registered in Google Apps SMTP Relay service doesn't match domain of
550-5.7.1 the accountthis email is being sent from. If you are trying to relay
550-5.7.1 mail from a domain that isn't registered under your Googles Apps
550-5.7.1 account or has empty envelope-from, you must configure your mail
550-5.7.1 server either to use SMTP AUTH to identify the sending domain or to
550-5.7.1 present one of your domain names in the HELO or EHLO command. For
550-5.7.1 more information, please visit
550 5.7.1 https://support.google.com/a/answer/6140680#invalidcred kg2sm505213wjb.4 - gsmtp (in reply to MAIL FROM command)
社区高分解答
原帖链接 · konqi · CC BY-SA 3.0
Install postfix with apt-get install postfix.
When asked select "satellite system" or the option with smarthost. Accept the defaults of everything else for now.
Edit your main.cf according to the following file:
/etc/postfix/main.cf
# a file which should contain the google apps domain
myorigin = /etc/mailname
# if your google apps domain is in mydestination, remove it, or postfix will attempt to deliver your mail locally
mydestination = ...., localhost
# Google Apps Relay SMTP, must use Port 587 because, 25 is blocked
relayhost = [smtp-relay.gmail.com]:587
# Force ehlo behavior
smtp_always_send_ehlo = yes
smtp_helo_name = <yourappsdomainhere>
# Enable TLS
smtp_use_tls=yes
smtp_tls_CAfile = /etc/ssl/certs/ca-certificates.crt
# limit smtp to loopback interface & compute engine doesn't support ipv6
inet_interfaces = loopback-only
inet_protocols = ipv4
# These lines can be used, if the result is not as expected
# debug_peer_list = smtp-relay.gmail.com
# debug_peer_level = 2
Restart postfix with service postfix restart. All should be good.
This may not be the cleanest all all solutions, but it works for me.
摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。
