PHP邮件功能有时工作 [英] PHP mail function works sometimes

查看:175
本文介绍了PHP邮件功能有时工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在编写一个脚本,需要通过PHP邮件功能发送电子邮件。如下所示,它在发送电子邮件到Gmail帐户但不是我的域上的帐户时起作用。我们正在运行一个Exchange服务器。截至目前,电子邮件是从_www @ server发送的。有没有人知道php邮件和Exchange的问题(或者甚至是以下划线和Exchange?开头的电子邮件地址)?或者还有另外一个问题呢?



谢谢,



Jeff

  $ user = $ _POST ['email']; 

$ to =someone@domain.org;

$ subject =请求重置EduTube密码;

$ body =谢谢。 $ _POST ['email']。 使用EduTube密码重置系统。\\\
\\\
;
$ body。=请点击以下链接,或将其复制并粘贴到浏览器中以重置密码。
$ body。=http://testing.domain.org/reset.php?user=。 $用户;

$ headers =From:someone@domain.org;

$ from =EduTube密码重置系统;

if(mail($ to,$ subject,$ body,$ headers)){

echo您的电子邮件已发送,请稍后检查您的收件箱。
echo< br />< a href ='http://testing.domain.org'>点击< / a>;

}


解决方案

mail )的传递功能在将邮件交给SMTP服务器时结束。它的唯一责任就是将现实世界等同于把信封放到角落里的邮箱里。邮政服务的其余部分(清空盒子,通过处理中心运行,将其运送到收件人的国家/地区等)完全不在mail()范围之外。只要信封掉入邮箱,mail()将返回true并假装它被传递。



所以...检查你的SMTP服务器的日志,看看真的发生在邮件中。也许它被接收者标记为垃圾邮件并退回。也许它被困在一个队列等等...只有日志会告诉你这个 - 你可以看到/在PHP中做的任何事情都是无用的,因为PHP和mail()只可能是电子邮件发送/传递过程的1%其他99%的东西有问题。


I am writing a script that needs to send an e-mail through the PHP mail function. As it is written below, it works when sending an e-mail to a gmail account, but not an account on my domain. We are running an Exchange server. As of now, the e-mails are sent from _www@server. Does anyone know of an issue with php mail and Exchange (or maybe even e-mail addresses beginning with an underscore and Exchange??)? Or perhaps there is another issue here? The mail function will return true no matter what.

Thank you,

Jeff

$user = $_POST['email'];

$to = "someone@domain.org";

$subject = "Request to Reset EduTube Password";

$body = "Thank you " . $_POST['email'] . " for using the EduTube Password Reset System.\n\n";
$body .= "Please click the following link, or copy & paste it into your browser to reset your password.\n\n";
$body .= "http://testing.domain.org/reset.php?user=" . $user;

$headers = "From: someone@domain.org";

$from = "EduTube Password Reset System";

if (mail($to, $subject, $body, $headers)){

echo "Your email has been sent.  Please check your inbox shortly.";
echo "<br/><a href='http://testing.domain.org'>Click</a>";

}

解决方案

mail()'s delivery function ends when it hands off your mail to the SMTP server. Its sole responsibility is the real-world equivalent of taking your envelope and dropping it into the mailbox on the corner. The rest of the postal service (emptying that box, running it through processing centers, flying it to the recipient's country/city, etc...) is completely outside of mail()'s scope. As long as the envelope drops into the mailbox, mail() will return true and pretend it was delivered.

So... check your SMTP server's logs to see what really happened to the mail. Maybe it got marked as spam by the receiver and bounced. Maybe it's stuck in a queue somewhere, etc... Only the logs will tell you this - anything you can see/do in PHP is useless, because PHP and mail() only do maybe 1% of the email sending/delivery process, and something's wrong in that other 99%.

这篇关于PHP邮件功能有时工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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