网上有一百万篇关于这个错误的帖子:无法在"mail.OURDOMAIN.com“端口25连接到邮件服务器,在php.ini中验证您的"SMTP”和"smtp_port“设置或使用ini_set()
以下是事实:
在我们的站点被迫加入公司的大型SMTP服务器池之前,我们的配置工作正常(使用由另一个组管理的SMTP服务器)。一旦我们将SMTP服务器条目指向新的SMTP服务器,就会出现“无法连接”的问题。
我可以远程登录到mail.OURDOMAIN.com 25并通过手动成功地发送一封测试邮件--它应该可以工作。
我在php.ini中有了正确的设置,并且我已经重新启动了the服务器。
我还对这些设置使用了ini_set(),并获得了相同的结果。
非常奇怪..。这里有什么建议吗?
我使用下面的代码来测试:
<?php
//change this to your email.
$to = "joe.guy@OURDOMAIN.com";
$from = "joe.guy@OURDOMAIN.com";
$subject = "Hello! This is HTML email";
$message = "hello";
$headers = "From: $from\r\n";
$headers .= "Content-type: text/html\r\n";
mail($to, $subject, $message,$headers);
echo "Message has been sent....!";
?>
以下是我的php.ini设置:
[mail function]
; For Win32 only.
; http://php.net/smtp
SMTP = mail.OURDOMAIN.com
; http://php.net/smtp-port
smtp_port = 25
; For Win32 only.
; http://php.net/sendmail-from
;sendmail_from = joe.guy@OURDOMAIN.com
; For Unix only. You may supply arguments as well (default: "sendmail -t -i").
; http://php.net/sendmail-path
;sendmail_path = "\"C:\xampp\sendmail\sendmail.exe\" -t"
发布于 2012-01-17 23:02:25
请尝试使用域的ip地址而不是名称。这对我来说已经奏效了很多次。
[mail function]
; For Win32 only.
; http://php.net/smtp
SMTP = 127.0.0.1
即:您自己的ip smtp服务器ip地址
https://stackoverflow.com/questions/8902866
复制相似问题