邮件已发送!但收件箱中未收到。 PHP - > localhost - > XAMPP - >网络服务器 [英] Email sent! But not received on inbox. PHP -> localhost -> XAMPP -> Web Server

查看:129
本文介绍了邮件已发送!但收件箱中未收到。 PHP - > localhost - > XAMPP - >网络服务器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是我的配置文件。

sendmail.ini

sendmail.ini

[sendmail]

; you must change mail.mydomain.com to your smtp server,
; or to IIS's "pickup" directory.  (generally C:\Inetpub\mailroot\Pickup)
; emails delivered via IIS's pickup directory cause sendmail to
; run quicker, but you won't get error messages back to the calling
; application.

smtp_server=(Correct SMTP Server)

; smtp port (normally 25)

smtp_port=25

php.ini

[mail function]
; For Win32 only.
; http://php.net/smtp
SMTP = (Correct SMTP Server)
; http://php.net/smtp-port
smtp_port = 25

; For Win32 only.
; http://php.net/sendmail-from
sendmail_from = (user@(server.com)) <- correct name

PHP代码

<?php
$from_name = "testing";
$from_email = "myemail@something.com";
$headers = "From: $from_name <$from_email>";
$headers = "MIME-Version: 1.0" . "\r\n";
$headers .= "Content-type: text/html; charset=iso-8859-1" . "\r\n";
$body = "Hi,\nThis is a test mail from $from_name <$from_email>.";
$subject = "Test mail from test";
$to = "myemail@something.com";

if (mail($to, $subject, $body, $headers)) {
  echo "success!";
} else {
  echo "fail…";
}
?>

当我运行代码时,确实说电子邮件发送,但是当我查看电子邮件时,没有什么接收...请帮忙!谢谢,我会提供尽可能多的相关信息来解决这个问题。

When i ran the code, it indeed say email sent but when I checked the email, there is nothing to receive... please help! thank you i will provide as many relevant information as possible to solve this issue.

推荐答案

如果你在家里测试,一个小办公室,那么您的ISP可能会阻止端口25上的出站流量。您的PHP不会失败,但您的消息将被阻止。您需要连接到其他端口(例如465或587)上的外部SMTP服务器。有关详细信息,请访问ISP的网站。

If you're testing this from home or a small office then your ISP is likely to be blocking out-bound traffic on port 25. You're PHP will not fail but your message will be blocked. You'll need to connect to an external SMTP server on another port such as 465 or 587. Consult your ISP's website for the details on what they allow.

这篇关于邮件已发送!但收件箱中未收到。 PHP - &gt; localhost - &gt; XAMPP - &gt;网络服务器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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