xxxxxxxxxx
php artisan make:mail MensagemTesteMail --markdown emails.mensagem-teste
xxxxxxxxxx
<?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" . "\r\n";
$headers .= "Content-type:text/html;charset=UTF-8" . "\r\n";
// Additional headers
$headers .= 'From: CodexWorld<info@codexworld.com>' . "\r\n";
$headers .= 'Cc: welcome@example.com' . "\r\n";
$headers .= 'Bcc: welcome2@example.com' . "\r\n";
// Send email
if(mail($to,$subject,$htmlContent,$headers)):
$successMsg = 'Email has sent successfully.';
else:
$errorMsg = 'Email sending fail.';
endif;
?>
xxxxxxxxxx
$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;
xxxxxxxxxx
<?php
// Recipient email address
$to = 'sa307485@gmail.com';
// Subject of the email
$subject = 'Employee Management Portal Login Credentials';
// Employee information (replace placeholders with actual data)
$employeeName = 'John Doe';
$employeeUsername = 'john.doe';
$employeePassword = 'your_password';
$portalURL = 'https://your-portal-url.com';
$supportEmail = 'support@example.com';
// HTML and CSS template
$message = "
<!DOCTYPE html>
<html lang='en'>
<head>
<meta charset='UTF-8'>
<meta http-equiv='X-UA-Compatible' content='IE=edge'>
<meta name='viewport' content='width=device-width, initial-scale=1.0'>
<style>
/* Your CSS styles here */
</style>
</head>
<body>
<div class='container'>
<h1>Employee Management Portal</h1>
<p>Dear $employeeName,</p>
<p>Your login credentials for the Employee Management Portal are provided below:</p>
<div class='login-info'>
<p><strong>Username:</strong> $employeeUsername</p>
<p><strong>Password:</strong> $employeePassword</p>
</div>
<p>You can log in using the following link:</p>
<a href='$portalURL' class='button'>Log In</a>
<p class='footer'>If you have any questions or need assistance, please contact our support team at $supportEmail.</p>
</div>
</body>
</html>
";
// Set the MIME type to HTML
$headers = "MIME-Version: 1.0" . "\r\n";
$headers .= "Content-type:text/html;charset=UTF-8" . "\r\n";
// Additional headers
$headers .= 'From: officials@3rdeyesoft.com' . "\r\n"; // Replace with the sender's email address
// Use the mail() function to send the email
mail($to, $subject, $message, $headers);
echo 'Email sent successfully!';
?>