PHP邮件功能中的奇怪行为,地址不存在 [英] Strange behavior in PHP mail function, address does not exist

查看:110
本文介绍了PHP邮件功能中的奇怪行为,地址不存在的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我最近有一个客户端的这个问题。代码为:

  ini_set(sendmail_from,noreply @< current-domain> .com); 

// $ target_email已被验证为值用户名。
// $ subject是一个简单的String。
// $ message是一个HTML消息。
mail($ target_email,$ subject,$ message);

当我在我的机器上测试这个,它工作正常。当我在家里,在Windows 2000(IE6),XP(四个不同的机器和一个VirtualBox实例)(IE6和7,Opera 9,Firefox 3)和Vista(IE 7)上测试它,以及通过Konquerer和Ubuntu上的Firefox(在两台不同的机器上),它工作正常(我没有Mac)。我在四个不同的网络和三个不同的县尝试了这个网站。我做了一切可以打破这个网站,我没有收到任何错误,电子邮件是从@< current-domain> .com到现在的地址。



当我的客户端在他的办公室进行测试时,他收到一个SMTP错误,称该名称不正确@< current-domain> .com不存在,并且没有收到该电子邮件。但是在我的服务器上运行时,相同的线路运行正常(基本的LAMP设置运行PHP 5.3,它们具有Windows 5.2.6)。



究竟发生了什么?我最好的猜测是这是一些奇怪的Windows服务器问题,我还没有雾气,还有什么可以。不幸的是,我无法看到他们如何配置本地机器来测试这个理论。

解决方案

我的猜测:客户端SMTP服务器被配置为仅中继邮件已知(例如:从Active Directory)地址和拒绝(合理地,有人可能会争辩)所有其他发件人?客户端域中是否存在不正确的地址?



尝试从已知良好的user@clientdomain.com地址发送邮件,telnet到smtp服务器,...试图缩小问题。 / p>

I recently had this issue with a client. The code read:

ini_set( "sendmail_from", "noreply@<current-domain>.com" );

// $target_email has been validated as a value username.
// $subject is a simple String.
// $message is an HTML message.
mail( $target_email, $subject, $message );

When I tested this on my machine, it worked fine. When I tested it at home, at work, on Windows 2000 (IE6), XP (four different machines, and a VirtualBox instance) (IE6 & 7, Opera 9, Firefox 3), and Vista (IE 7), as well as through Konquerer and Firefox on Ubuntu (on two different machines), it worked fine (I don't have a Mac). I had tried the website on four different networks and in three different counties. I did everything I could to break this site, and I received no error, and the email came from noreply@<current-domain>.com to the expected address promptly.

When my client tested it at his office he got an SMTP error, saying that the name noreply@<current-domain>.com does not exist and he did not receive the email. But the same lines work fine when running on my server (basic LAMP set up running PHP 5.3, they have Windows 5.2.6).

What, exactly, happened? My best guess was that this is some bizarre windows server issue, I don't have the foggiest what else it could be. Unfortunately, I was not able to see how they configured their local machines to test this theory.

解决方案

My guess: the clients SMTP server is configured to only relay mail for known (for example: from Active Directory) adresses and reject (rightfully, one might argue) all other 'senders'? Does the noreply address exist in the clients domain?

Try sending a mail from a 'known' good user@clientdomain.com address, telnet to the smtp server, ... to try to narrow down the problem.

这篇关于PHP邮件功能中的奇怪行为,地址不存在的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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