$to = 'user@example.com';
$from = 'sender@example.com';
$fromName = 'SenderName';
$subject = "Send HTML Email in PHP by onitroad";
$htmlContent = '
<html>
<head>
<title>Welcome to onitroad</title>
</head>
<body>
<h1>Thanks you for joining with us!</h1>
<table cellspacing="0" style="border: 2px dashed #FB4314; width: 100%;">
<tr>
<th>Name:</th><td>onitroad</td>
</tr>
<tr style="background-color: #e0e0e0;">
<th>Email:</th><td>contact@onitroad.com</td>
</tr>
<tr>
<th>Website:</th><td><a href="http://www.onitroad.com">www.onitroad.com</a></td>
</tr>
</table>
</body>
</html>';
//Set content-type header for sending HTML email
$headers = "MIME-Version: 1.0" . "
";
$headers .= "Content-type:text/html;charset=UTF-8" . "
";
//Additional headers
$headers .= 'From: '.$fromName.'<'.$from.'>' . "
";
$headers .= 'Cc: welcome@example.com' . "
";
$headers .= 'Bcc: welcome2@example.com' . "
";
//Send email
if(mail($to, $subject, $htmlContent, $headers)){
echo 'Email has sent successfully.';
}else{
echo 'Email sending failed.';
}
|