English 中文(简体)
PHP 邮件 () 功能不工作, 返回没有错误, 但邮件没有回复
原标题:PHP mail() function not working, returns no errors but mail not recieved

为了试图从php脚本发送邮件,我正在用此代码测试邮件()函数 :

<?php  
ini_set("display_errors", "1");
error_reporting(E_ALL);
$to =  [email protected] ;
$message =  test ;
$from =  [email protected] ;
$subject =  Test ;
$headers = "From: $from
";
mail($to, $subject, $message, $headers) or die ("Message not sent");
?>  

This is not the only code I have tried it with, but nothing seems to be working. One of the reasons I am inquiring here is because it returns no errors whatsoever. I get no indication of any error at all, except that the mail never reaches it s destination. Things that I have done to try and fix the problem:

  1. Changed the SMTP in php.ini from localhost to gmail s smtp
  2. Checked spam filters and outboxes on both ends
  3. Tried various methods of error reporting
  4. Tried several different functions for sending mail
  5. Checked seemingly related things in phpinfo() and looked them up to no avail

我认为这也许与我的终端的发送邮件功能有问题, 但我无法测试或修正任何与发送邮件功能有关的问题。

我正用OS X 10.4 老虎和PHP 5.

问题回答

php.ini 中的 SMTP 设置仅用于 Windows 。 在其它系统中, 本地 MTA (Sendmail) 总是被使用, 而您提供的 SMTP 设置被静默忽略。 如果您想要使用 Gmail, 请确定您在您的 MTA 中配置它 。

检查发件系统上的 Sendmail 邮件日志。 您应该可以找到信件发送的提示 。





相关问题
Brute-force/DoS prevention in PHP [closed]

I am trying to write a script to prevent brute-force login attempts in a website I m building. The logic goes something like this: User sends login information. Check if username and password is ...

please can anyone check this while loop and if condition

<?php $con=mysql_connect("localhost","mts","mts"); if(!con) { die( unable to connect . mysql_error()); } mysql_select_db("mts",$con); /* date_default_timezone_set ("Asia/Calcutta"); $date = ...

定值美元

如何确认来自正确来源的数字。

Generating a drop down list of timezones with PHP

Most sites need some way to show the dates on the site in the users preferred timezone. Below are two lists that I found and then one method using the built in PHP DateTime class in PHP 5. I need ...

Text as watermarking in PHP

I want to create text as a watermark for an image. the water mark should have the following properties front: Impact color: white opacity: 31% Font style: regular, bold Bevel and Emboss size: 30 ...

How does php cast boolean variables?

How does php cast boolean variables? I was trying to save a boolean value to an array: $result["Users"]["is_login"] = true; but when I use debug the is_login value is blank. and when I do ...

热门标签