Search
 
SCRIPT & CODE EXAMPLE
 

PHP

send email template via php

<?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;
?>
Comment

create email template php

$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;
Comment

php mail template

php artisan make:mail MensagemTesteMail --markdown emails.mensagem-teste
Comment

PREVIOUS NEXT
Code Example
Php :: php function to remove 0 value from array 
Php :: php convert array to json 
Php :: Woocommerce get image galleries by product id 
Php :: withsuccess laravel 8 
Php :: session forget laravel 
Php :: html in php function 
Php :: Image not found or type unknown in pdf 
Php :: create weekly calendar in php 
Php :: laravel validation check value should be one of in array 
Php :: woocommerce order status change 
Php :: php xml to json 
Php :: laravel collection collapse 
Php :: php list *files 
Php :: how-to-generate-an-xlsx-using-php 
Php :: PHP 2-Dimentional array 
Php :: php key_exists 
Php :: find object in array php 
Php :: array to comma separated string php 
Php :: Creating (Declaring) PHP Variables 
Php :: php call method from another class 
Php :: php library to convert html to amp 
Php :: Predefined Constants php 
Php :: ternary in php 
Php :: PHP $argv echo 
Php :: php file storage 
Php :: how to get the previous page url in php 
Php :: laravel get from model 
Php :: laravel new line in session flash message 
Php :: laravel eloquent relationship 
Php :: php get array key like 
ADD CONTENT
Topic
Content
Source link
Name
9+3 =