PHP mail()函数不会发送到gmail,但会发送到我的非Gmail帐户 [英] PHP mail() function will not send to gmail but will send to my non-gmail account

查看:106
本文介绍了PHP mail()函数不会发送到gmail,但会发送到我的非Gmail帐户的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

由于某些原因,php mail()功能在正在建立的站点上无法正常工作。我试图将问题解决到最简单的形式,并提出了这个文件:

For some reason the php mail() function is not working properly on a site I am building. I tried to troubleshoot the issue down to its simplest form, and came up with this file:

<?php
mail('myEmail@gmail.com', 'the subject', 'the message', 'From: webmaster@example.com', '-fwebmaster@example.com');
?>

但是当我使用非Gmail账号时,我收到了这个消息。我很失落,已经尝试了一切来解决这个问题。我开始认为这是一个晦涩的主机/服务器问题。您可以在这里查看服务器规格: http://aopmfg.com/php.php

when myEmail is a gmail account, I never recieve the message. However when I use a non-gmail account, I do recieve the message. I am at a loss and have tried everything to figure this out. I am starting to think it is an obscure host/server issue. You can see the server specs here: http://aopmfg.com/php.php

任何想法?

编辑 - 我还要补充一点,几周前,这是一切正常,最后一次我测试了。从那以后,没有重大的代码更改。

EDIT - let me also add that this was all working fine a few weeks ago, the last time I tested it. No significant code changes since then at all.

编辑2 - 阅读类似的文章后,我尝试添加From和Reply-To标题...仍然没有运气。新代码:

EDIT 2 - After reading a similar post I tried adding From and Reply-To headers... still no luck. New code:

<?
$headers = 'From: <some@email.com>' . "\r\n" .
'Reply-To: <some@email.com>';

mail('<myEmail@gmail.com>', 'the subject', 'the message', $headers,
'-fwebmaster@example.com');
?>


推荐答案

事实证明,Google阻止了我的服务器,在同一个服务器上被黑客入侵并用于垃圾邮件。

It turns out that Google blocked my server because another site on the same server was hacked and used for spam.

要测试并确保这是服务器的问题,我创建了一个简单的PHP文件,将发送电子邮件在刷新页面到我的电子邮件地址。当我发送到我的基于交换机的电子邮件地址,但不是任何Google相关帐户时,它工作。

To test and ensure that it was a problem with the server, I created a simple PHP file that would send an email to my email address on page refresh. It worked when I sent to my exchange-based email address, but not to any Google-related accounts.

代码:


Code:

$headers = 'From: <test@test.com>' . "\r\n" .
'Reply-To: <test@test.com>';

mail('<myEmail@gmail.com>', 'the subject', 'the message', $headers,
  '-fwebmaster@example.com');
?>

感谢您的帮助。

这篇关于PHP mail()函数不会发送到gmail,但会发送到我的非Gmail帐户的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆