【问题标题】:Though the mail() returns true, email is not received.Is there anything wrong with the configuration?虽然mail()返回true,但是没有收到邮件。是不是配置有问题?
【发布时间】:2013-03-13 01:32:20
【问题描述】:

以下分别是php.inisendmail.ini中的配置:

[mail function]
sendmail_path = ""\"E:\Installed_Apps\xampp\sendmail\sendmail.exe\" -t""
mail.add_x_header = Off

[sendmail]
SMTP = localhost
smtp_port = 25
smtp_server=smtp.gmail.com
smtp_port=587
smtp_ssl=auto
error_logfile=error.log
auth_username=my_gmail_address
auth_password=my_xxxxxx
pop3_server=
pop3_username= 
pop3_password=
force_recipient=
hostname=

我尝试发送电子邮件为:

<?php
$sent = mail('to_someone@hotmail.com','Message sent from XAMPP','Hey ! I just sent you a message using XAMPP');
if($sent) {
    echo "Mail sent successfully";
}else {
    echo "Sending failed";
}

对于$sent,我总是收到true,但上述地址没有收到电子邮件。这可能是什么原因?是不是配置文件有问题?

注意: 我上传了 php.inisendmail.ini @github,我在 25 日运行水银

【问题讨论】:

  • 您是否阅读了文档页面上的注释和 cmets? php.net/mail
  • 来自the manual "重要的是要注意,仅仅因为邮件被接受投递,并不意味着邮件实际上会到达预定目的地。"
  • 检查smtp服务器是否作为windows服务运行

标签: php windows email xampp


【解决方案1】:

您正在积极将其设置为使用mailtodisk.exe,这是一个简单地接收电子邮件并将其保存到文件夹的程序 - 它根本不会尝试发送电子邮件,它只是一个检查工具确保您的电子邮件看起来正确。

来自关于sendmail_path的文档:

如果设置,smtp、smtp_port 和 sendmail_from 将被忽略,并且 执行指定的命令。

尝试注释掉 sendmail_path 并检查您的计算机上的端口 25 上是否运行了 SMTP 服务器。

【讨论】:

  • 我其实已经注释掉了mailtodisk.exe,没有注释掉"\"E:\Installed_Apps\xampp\sendmail\sendmail.exe\" -t"
  • 您是否检查过sendmail.log 文件(应该与sendmail.exe 位于同一目录中)。它可能会揭示为什么没有发送电子邮件。如前所述,只要 sendmail 处理输入,无论是否发送,PHP 在很多情况下都会报告“True”。
  • 我没有找到sendmail.log
  • 另外mercury25 上运行
  • 我已经上传了php.inisendmail.ini@github。有什么问题吗?
猜你喜欢
  • 1970-01-01
  • 2015-05-17
  • 2017-07-21
  • 2014-07-14
  • 2013-06-16
  • 1970-01-01
  • 1970-01-01
  • 2018-12-19
  • 2016-01-16
相关资源
最近更新 更多