<?php
$to = 'user@example.com';
$subject = "Send HTML Email Using PHP";
$htmlContent = '
<html>
<body>
<h1>Send HTML Email Using PHP</h1>
<p>This is a HTMl email using PHP by CodexWorld</p>
</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: CodexWorld<info@codexworld.com>' . "
";
$headers .= 'Cc: welcome@example.com' . "
";
$headers .= 'Bcc: welcome2@example.com' . "
";
// Send email
if(mail($to,$subject,$htmlContent,$headers)):
$successMsg = 'Email has sent successfully.';
else:
$errorMsg = 'Email sending fail.';
endif;
?>
$variables = array();
$variables['name'] = "Robert";
$variables['age'] = "30";
$template = file_get_contents("template.html");
foreach($variables as $key => $value)
{
$template = str_replace('{{ '.$key.' }}', $value, $template);
}
echo $template;
php artisan make:mail MensagemTesteMail --markdown emails.mensagem-teste