将后缀设置为使用Google Apps SMTP中继的SMTP中继的步骤是什么? networking上有大量的教程解释了如何使用带有SASLauthentication的smtp.gmail.com网关,但是我找不到这里描述的Google Apps中继smtp-relay.google.com的工作configuration,尤其是一个这是特定于Google Compute的。
我已经设置了smtp中继服务,在这里描述了 “我的域名只有地址”,并validation了IP实际上是我连接的IP地址。
我知道Google计算机不允许将端口25作为此处所述的输出端口。
我正在使用Debian Linux或Debian衍生物。
我已经在文档中详细设置了postfix,但是我在mail.log中得到的是:
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)
用apt-get install postfix 。 当被问及select“卫星系统”还是select与智能主机。 现在接受所有其他的默认设置。
根据以下文件编辑您的main.cf:
/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
用service postfix restart启动重新启动postfix。 一切都应该好。
这可能不是最干净的所有解决scheme,但它对我有用。
我已经search了几天的互联网find你和我正在寻找的解决scheme。
请确保您已经在您的Google Apps帐户的Apps> Google Apps> Gmail>高级设置下设置了SMTP中继设置,如下所示:
确保你已经安装了postfix和libsasl2-modules。
sudo apt-get update sudo apt-get install postfix sudo apt-get install libsasl2-modules
后缀configuration
在Postfixconfiguration期间设置以下设置:
你的/etc/postfix/main.cf文件应该如下所示:
myhostname = yourdomain.com smtpd_banner = $myhostname ESMTP $mail_name (Debian/GNU) 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 smtpd_relay_restrictions = permit_mynetworks permit_sasl_authenticated defer_unauth_destination alias_maps = hash:/etc/aliases alias_database = hash:/etc/aliases myorigin = /etc/mailname mydestination = yourdomain.com relayhost = [smtp.gmail.com]:587 mynetworks = 127.0.0.0/8 [::ffff:127.0.0.0]/104 [::1]/128 mailbox_size_limit = 0 recipient_delimiter = + inet_interfaces = all # Use IPv4 protocol inet_protocols = ipv4 # enable SASL authentication smtp_sasl_auth_enable = yes # disallow methods that allow anonymous authentication. smtp_sasl_security_options = noanonymous # where to find sasl_passwd smtp_sasl_password_maps = hash:/etc/postfix/sasl/passwd # Enable STARTTLS encryption smtp_use_tls = yes # where to find CA certificates smtp_tls_CAfile = /etc/ssl/certs/ca-certificates.crt
创build一个/etc/postfix/sasl/passwd文件并添加你的Google Apps用户名和密码,如下所示:
[smtp.gmail.com]:587 [email protected]:yourpassword
现在通过运行postmap命令为Postfix创build散列数据库文件:
sudo postmap /etc/postfix/sasl/passwd
保护您的密码和哈希数据库文件,以便只有root可以读取和写入它们:
sudo chown root:root /etc/postfix/sasl/passwd /etc/postfix/sasl/passwd.db sudo chmod 0600 /etc/postfix/sasl/passwd /etc/postfix/sasl/passwd.db
重新启动Postfix作者:
sudo /etc/init.d/postfix restart
如果你已经安装了mailutils你可以testing发送邮件:
echo "body of your email" | mail -s "This is a Subject" -a "From: [email protected]" [email protected]
如果您的邮件没有收到,请检查您的mail.log文件是否有任何错误消息:
sudo tail -f /var/log/mail.log
我写了一篇更详细的文章: http : //dev.robbertvermeulen.com/postfix-google-apps-smtp-relay-google-compute-engine/