What is the PHP mail function

The PHP mail() function allows you to send emails directly from a script.
PHP use the mail() function to send an email. PHP Mail() function requires three mandatory parameters and two optional parameters. First Three parameters specify the email address, the subject of the mail and the actual message of mail.

mail( to, subject, message, headers, parameters );

Simple example of sending php mail.

Following example will send a simple plain text email to xyz@example.com.

  <?php   
  $to = "xyz@example.com";
  $subject = "My subject";
  $txt = "Hello world! This is simple plain text php mail";
  $headers = "From: webmaster@example.com" . "\r\n" .
  "CC: somebodyelse@example.com";

  mail($to,$subject,$txt,$headers);
?>

How to send HTML email

  <?php   
  $to = "xyz@example.com";
  $subject = "My subject";
  $txt = "Hello world! This is simple plain text php mail";
  $headers = "From: webmaster@example.com" . "\r\n" .
  "CC: somebodyelse@example.com";

  mail($to,$subject,$txt,$headers);
?>
<html>
<head>
<title>Sending HTML email using PHP</title>
</head>
<body>
<?php
$to = "xyz@example.com";
$subject = "This is subject of mail";
$message = "<b>This is HTML message.</b>";
$message .= "<h1>This is headline.</h1>";

// Always set content-type when sending HTML email
$headers = "MIME-Version: 1.0" . "\r\n";
$headers .= "Content-type:text/html;charset=UTF-8" . "\r\n";
$header = "From: PHPKIDA  \r\n";

$mailto = mail ($to,$subject,$message,$header);
if( $mailto == true )
{     echo "Message sent successfully...";   }
else   {     echo "Message could not be sent...";   }
?>
</body>
</html>

How skip span folder / How can we skip or send direct mail into inbox

Just put @ symbol before your mail function.

@mail ($to,$subject,$message,$header);
// That code will be send direct mail into inbox

Sign up for weekly update

Milkshake is almost ready. If you're interested in testing it out, then sign up below to get exclusive access.