邮件功能在 PHP 中不起作用 [英] Mail function is not working in PHP

查看:35
本文介绍了邮件功能在 PHP 中不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

<?php

if (isset($_POST['submit']))
{
    //if "email" is filled out, proceed

    $name=  mysql_real_escape_string($_POST['name']);
    $phone=  mysql_real_escape_string($_POST['phone']);

    $to = "admin@gmail.com";
    $subject = "Customer Intrested";
    $message = "Buyer Information and Intrested in land.";
    $message.= "Customer Name :".$name."
";
    $message.= "Customer Phone :".$phone."
";  

    $mail=mail($to, "Subject: $subject",$message );
    if($mail){
        echo "success";
    } else {
        echo "failed."; 
    }
?>

我正在使用上面的代码发送电子邮件..但我无法得到结果..它总是显示谢谢消息"..

I am using the above code to send email..but i am unable to get the result..it always showing the "Thank you message"..

我可以获取 name 和 phone 的值.

I can able to get the values of name and phone.

如何解决这个问题?

推荐答案

mail($to, "Subject: $subject",$message );
echo "Thank you for using our mail form";

而不是这个,首先检查邮件是否发送

instead of this ,first check if the mail is sent

$mail=mail($to, "Subject: $subject",$message );
if($mail){
  echo "Thank you for using our mail form";
}else{
  echo "Mail sending failed."; 
}

实际上你可以知道你的邮件功能是否在工作

By this actually u can know whether your mail function in working or not

如果它不起作用.问题可能出在本地主机中的 SMTP 设置

if it is not working.the problem can be with SMTP settings in your localhost

如果未启用,则在 php 中启用错误

enable errors in php if not enabled using

ini_set('display_errors',1);

这篇关于邮件功能在 PHP 中不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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