This question already has an answer here:
这个问题在这里已有答案:
- PHP mail function doesn't complete sending of e-mail 24 answers
PHP邮件功能没有完成发送电子邮件24个答案
I have a mail function in my PHP file . When I excecute the file it doesn't give me any error messages but the email is not sent either. I have installed and started the Mercury Mail.
我的PHP文件中有一个邮件功能。当我执行该文件时,它不会给我任何错误消息,但电子邮件也不会发送。我已经安装并启动了Mercury Mail。
Here is my code:
这是我的代码:
$result = mysql_query("select email from user
where username='$username'");
$email = mysql_result($result, 0, "email");
$from = "another_emailgmail.com";
$mesg = "Your password have been changed";
if (mail($email, "Login information", $mesg, $from))
return true;
I have looking in another similar post but it seems they have not installed Mercury Mail and they dont't have the same problem.
我在寻找另一个类似的帖子,但似乎他们没有安装Mercury Mail,他们也没有同样的问题。
3 个解决方案
#1
0
This code works out-the-box (change your e-mail address!). mail()
function return a bool value, then if it returns TRUE you have to check your system log and system e-mail spool looking for routing errors or something similar.
此代码开箱即用(更改您的电子邮件地址!)。 mail()函数返回一个bool值,如果它返回TRUE,你必须检查你的系统日志和系统电子邮件假脱机查找路由错误或类似的东西。
<?php
if(mail('some_email@gmail.com','E-mail subject',"E-mail body\r\n")){
echo 'Works'."\n";
}else{
echo 'Failed'."\n";
}
#2
0
mail($mailto, $subject,stripslashes($message), $headers);
Headers Can be set as below
标题可以设置如下
$headers .= 'From:from@gmail.com' . "\r\n";
#3
0
Try this.changes the fields according to your needs.just change the data according to your need
试试这个。根据你的需要改变字段。只需根据你的需要改变数据
$headers = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
$headers .= "To: $mydata->name <$mydata->email>" . "\r\n";
$headers .= "From: demo.com <contact@demo.com>" . "\r\n";
mail($mydata->email, $subject, $message, $headers);
#1
0
This code works out-the-box (change your e-mail address!). mail()
function return a bool value, then if it returns TRUE you have to check your system log and system e-mail spool looking for routing errors or something similar.
此代码开箱即用(更改您的电子邮件地址!)。 mail()函数返回一个bool值,如果它返回TRUE,你必须检查你的系统日志和系统电子邮件假脱机查找路由错误或类似的东西。
<?php
if(mail('some_email@gmail.com','E-mail subject',"E-mail body\r\n")){
echo 'Works'."\n";
}else{
echo 'Failed'."\n";
}
#2
0
mail($mailto, $subject,stripslashes($message), $headers);
Headers Can be set as below
标题可以设置如下
$headers .= 'From:from@gmail.com' . "\r\n";
#3
0
Try this.changes the fields according to your needs.just change the data according to your need
试试这个。根据你的需要改变字段。只需根据你的需要改变数据
$headers = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
$headers .= "To: $mydata->name <$mydata->email>" . "\r\n";
$headers .= "From: demo.com <contact@demo.com>" . "\r\n";
mail($mydata->email, $subject, $message, $headers);