Here is the simple using of php mail() function codes :
<?php
$from = "From email goes here";
$to = "To email goes here";
ini_set("display_errors", "On");
ini_set("sendmail_from", $from);
ini_set("SMTP", "localhost");
ini_set("smtp_port", "25");
$subject = "Hello, This is subject";
$message = "<p style='color: green;font-weight: bold;'>Hello World, This is Body</p>";
$headers = 'MIME-Version: 1.0' . "\r\n";
//$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
$headers .= 'Content-Type: text/html; Charset=UTF-8' . "\r\n";
$headers .= 'From: Birthday Reminder <' . $from . '>' . "\r\n";
$headers .= 'To: Mary <' . $to . '>' . "\r\n";
$headers .= 'Reply-To: Birthday Reminder <' . $from . '>' . "\r\n";
$headers .= 'X-Mailer: PHP/' . phpversion();
if(mail($to, $subject, $message,$headers))
{
echo("<p style='color: blue;font-weight: bold;'>Email Sent :D</p>");
}
else
{
echo("<p style='color: red;font-weight: bold;'>Email Message delivery failed...</p>");
}
?>
Why emails were sent using these codes always go to the spam folder?
Is the order of headers ok?
Which extra headers should i use for prevent spam?
Edit :
I know there are some threads in stack about that.
But i am looking for an updated answers.
So it's not duplicate.