0

Now I tried to send mails through php mail function for a application . 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
        $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 . And I would like learn more .

Terance Wijesuriya
  • 1,928
  • 9
  • 31
  • 61

1 Answers1

1

You're third $headers line is missing the period.

$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";