简体   繁体   English

php mail()函数不适用于发送简单邮件

[英]php mail() function is not working for sending a simple mail

Now I tried to send mails through php mail function for a application . 现在,我尝试通过php邮件功能为应用程序发送邮件。 But the problem is , when I send a mail through this result is given as 'Message has sent' but actually I couldn't get any mails from this . 但是问题是,当我通过此结果发送邮件时,将其显示为“消息已发送”,但实际上我无法从中获得任何邮件。

This is my php code , 这是我的php代码,

<?php
        $name=$_POST['name'];
        $email=$_POST['email'];
        $phone=$_POST['phone']; 
        $message=$_POST['message'];

        $to='yyyy222@xxx.com';
        $subject='New mail';
        $headers  = 'MIME-Version: 1.0' . "\r\n";
        $headers .= "Content-type: text/html; charset=iso-8859-1\r\n";
        $headers='From : '.$email."r\n".
                 'Reply-To : '.$email."r\n";
        echo 'Starting send mail';
        echo '<br>';
        $sent=mail($to,$subject,$message,$headers);
        if(!$sent){
            echo 'There are problems in sending mails  <br>';
        }else{
            echo 'Message has sent';
            echo '<br>';
        }       
        echo 'Mail sent';
        echo '<br>';
   ?> 

Today is my first day in learning php . 今天是我学习php的第一天。 And I would like learn more . 我想了解更多。

You're third $headers line is missing the period. 您的第三个$ headers行缺少句点。

$headers='From : '.$email."r\n".
                 'Reply-To : '.$email."r\n";

This is what you have ^^ - This is what you should have: 这是您拥有的^^-这应该是您拥有的:

$headers .= 'From : '.$email."r\n".
                 'Reply-To : '.$email."r\n";

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM