如何通过外部SMTP中继中继所有本地邮件

时间:2021-07-04 18:11:06

I have Postfix 2.6.6 installed on my CentOS server. I use SendGrid for all outgoing mail, and have the following settings in my Postfix main.cf file...

我的CentOS服务器上安装了Postfix 2.6.6。我对所有外发邮件使用SendGrid,并在我的Postfix main.cf文件中进行以下设置...

smtp_sasl_auth_enable = yes
smtp_sasl_password_maps = static:Username:Password
smtp_sasl_security_options = noanonymous
smtp_tls_security_level = encrypt
header_size_limit = 4096000
relayhost = smtp.sendgrid.net:587
smtp_tls_CAfile = /home/artmgr/certs/gd_bundle-g2-g1.crt 

This server runs a few PHP sites that generate automated emails. Usually all email generated on the server is relayed to SendGrid. However, when sending to an email address that uses the same domain as the hostname of my server, the email lands in the root mailbox on the local server instead of being relayed to SendGrid.

该服务器运行一些生成自动电子邮件的PHP站点。通常,服务器上生成的所有电子邮件都会中继到SendGrid。但是,当发送到使用与我的服务器的主机名相同的域的电子邮件地址时,电子邮件将落在本地服务器上的根邮箱中,而不是中继到SendGrid。

For example, let's say the hostname of my server is mydomain.com. When an email is generated on the server to be sent to support@mydomain.com it lands in the root mailbox on the local server.

例如,假设我的服务器的主机名是mydomain.com。当在服务器上生成要发送到support@mydomain.com的电子邮件时,它将登陆本地服务器上的根邮箱。

Is there any way to tell Postfix to send all email, even mail that uses the local hostname, via the SendGrid relay?

有没有办法告诉Postfix通过SendGrid中继发送所有电子邮件,甚至是使用本地主机名的邮件?

1 个解决方案

#1


On a shell, run the following code,

在shell上,运行以下代码,

postconf -e "mydestination="
postfix reload

This will clear the mydestination variable, thus no mail is considered local.

这将清除mydestination变量,因此没有邮件被认为是本地邮件。

#1


On a shell, run the following code,

在shell上,运行以下代码,

postconf -e "mydestination="
postfix reload

This will clear the mydestination variable, thus no mail is considered local.

这将清除mydestination变量,因此没有邮件被认为是本地邮件。