sending mail from php code example
Example 1: php mail
<?php
$to = $_POST['email'];
$subject = "Email Subject";
$message = 'Dear '.$_POST['name'].',<br>';
$message .= "We welcome you to be part of family<br><br>";
$message .= "Regards,<br>";
// 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";
// More headers
$headers .= 'From: <[email protected]>' . "\r\n";
$headers .= 'Cc: [email protected]' . "\r\n";
mail($to,$subject,$message,$headers);
?>
Example 2: send email in php
<?php
ini_set( 'display_errors', 1 );
error_reporting( E_ALL );
$from = "[email protected]";
$to = "[email protected]";
$subject = "Checking PHP mail";
$message = "PHP mail works just fine";
$headers = "From:" . $from;
if(mail($to,$subject,$message, $headers)) {
echo "The email message was sent.";
} else {
echo "The email message was not sent.";
}
?>