1 min read
How To Send An Email With Mail Function Php
Mail function allows you to send an email from php script,below is an example of how it works
:
<?php
$to = 'to@mail.com';
$subject = "Email Subject";
$message = 'Dear '.$name.',<br>';
$message .= "This is an example email<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: <enquiry@example.com>' . "\r\n";
$headers .= 'Cc: cc@example.com' . "\r\n";
mail($to,$subject,$message,$headers);
?>