简体   繁体   English

Google企业应用套件:未接收到PHP邮件发送的来自同一域的电子邮件

[英]Google Apps: Not receiving email from same domain sent by PHP mail()

For testing the email sent by PHP mail() I have the following script called phpmail.php 为了测试PHP mail()发送的电子邮件,我有一个名为phpmail.php的脚本。

<?php

$to      = "david@domain.com david@gmail.com david@otherdomain.com";
$header  = "From: noreply@domain.com";
$subject = "Testing PHP email from domain.com";
$body    = "This is sent form the server.";

if (mail($to, $subject, $body, $header)) {
    echo("Message successfully sent!");
} else {
    echo("Message delivery failed...");
}

?>

it sends to 3 email addresses: 它发送到3个电子邮件地址:

  1. david@domain.com (Google Apps) david@domain.com(Google Apps)
  2. david@gmail.com (standard Gmail) david@gmail.com(标准Gmail)
  3. david@otherdomain.com (Also Google Apps) david@otherdomain.com(也有Google Apps)

the script is run from the server hosting the "domain.com" website. 该脚本是从托管“ domain.com”网站的服务器运行的。 While the same message is received by emails 2. and 3., it's not by 1. which is the same domain where PHP was executed. 虽然电子邮件2和3接收到相同的消息,但不是电子邮件1.接收到的,这是执行PHP的同一域。

Is there something I need to change from the server to make it work? 我需要从服务器进行更改以使其正常工作吗? Thank you. 谢谢。

Edit: The MX is setup correctly using instructions from 编辑:使用以下说明正确设置了MX

https://support.google.com/a/answer/174125?hl=en https://support.google.com/a/answer/174125?hl=en

I have another server using this settings and it's working correctly. 我有另一台服务器正在使用此设置,并且可以正常工作。 For some reason, it's not working with this server. 由于某种原因,它无法与此服务器一起使用。 I believe (fuzzy memory) it worked some time ago. 我相信(模糊记忆)它在一段时间前有效。

Solved the issue by changing the network hostname (it was same as the Google Apps) to something else following instruction from this site: 按照此站点上的说明将网络主机名(与Google Apps相同)更改为其他名称,从而解决了该问题:

http://www.rackspace.com/knowledge_center/article/centos-hostname-change http://www.rackspace.com/knowledge_center/article/centos-hostname-change

Are you running the first Google Apps domain on the same domain as the website is hosted? 您是否在与托管网站相同的域上运行第一个Google Apps域? It is likely that your server is configured to recognize 'internal' mail. 您的服务器可能已配置为识别“内部”邮件。 If this is the case, the mail is delivered to the local mailserver instead of the Google Apps mailserver. 在这种情况下,邮件将传递到本地邮件服务器,而不是Google Apps邮件服务器。

The solution is to configure the DNS (specifically MX) records of your (web) server to point to Google Apps. 解决方案是将您的(网络)服务器的DNS(特别是MX)记录配置为指向Google Apps。 This can be done easily if you have a control panel like DirectAdmin or Plesk. 如果您具有DirectAdmin或Plesk这样的控制面板,则可以轻松完成此操作。 If not, Google specific instructions for your setup. 如果不是,请按照Google的具体说明进行设置。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM