Hello reader's we discussed about "Send HTML email in php".
In this code we use Html tags in the " $message " for the better user interface.
example: " h1 " tag for heading and " p " tag for paragraph (write a message).
Hence You can use all HTML tags for creating a better user interface.
You can use the below code as simple example:-
<?php
$to = 'evontech@email.com';
$subject = 'Information';
$from = 'employee@email.com';
// To send HTML mail, the Content-type header must be set
$headers = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
// Create email headers
$headers .= 'From: '.$user_email."\r\n".
'Reply-To: '.$user_email."\r\n" .
'X-Mailer: PHP/' . phpversion();
// Compose a simple HTML email message
$message = '<html><body>';
$message .= '<h1 style="color:#f40;">Hello Team!</h1>';
$message .= '<p style="color:#080;font-size:18px;">Thanks for achieving the goal.</p>';
$message .= '</body></html>';
// Sending email
if(mail($to, $subject, $message, $headers)){
echo 'Your mail has been sent successfully.';
} else{
echo 'Unable to send email. Please try again.';
}
?>
0 Comment(s)