1

This is my code. I spent hours debugging it. I can't see the error. Why didn't I didn't receive the email?

if(isset($_POST['submit'])){
    $to = "admin@example.com";
    $subject = "Mesej Website";
    $from = $_POST['email'];                            
    $headers = "From: " . strip_tags($from) . "\r\n";
    $headers .= "Reply-To: ". strip_tags($from) . "\r\n";
    $headers .= "MIME-Version: 1.0\r\n";
    $headers .= "Content-Type: text/html; charset=ISO-8859-1\r\n";                              
    $message = '<html><body>';
    $message .= '<h3>Mesej Daripada '.$_POST['name'].'</h3>';
    $message .= '<div style="margin-top:20px;">'.$_POST['message'].'</div>';
    $message = '</body></html>';
    mail($to,$subject,$message,$headers) or die('mail sending error'); 
gsquaredxc
  • 1,024
  • 12
  • 28

1 Answers1

-1

The in built mail function of PHP needs configuration for sending the email.However, if you are using the third party hosting provider this should be already configured or else you need to configure it in php.ini file.

To avoid these configuration issues you can use the phpmailer library where you can all the parameters easily and in a more efficient way.

DeadCoderz
  • 237
  • 3
  • 8