Skip to main content

How to send custom email template in wordpress?

 Send custom email template in wordpress



$body = file_get_contents(WP_CONTENT_DIR . '/themes/Avada-Child-Theme/contact-email.html');
$body = str_replace("#name#",$_POST['quotename'],$body);
$body = str_replace("#email#",'<a style="color:#fff" href="mailto:'.$_POST['quoteemail'].'">'.$_POST['quoteemail'].'</a>',$body);
$body = str_replace("#mobile#",$_POST['quotemobile'],$body);
$body = str_replace("#message#",$_POST['quotemessage'],$body);


$toadmin = "Scott@USAPrivateMoney.com, Jack@USAPrivateMoney.com, Prospect.60008.140@realtyjuggler.com";

$adminmessage = "You just got one more visitor that is ".$quoteemail." who filled proof of funds letter. Please find the attachment";


$headers = 'From: "' . $quotename . '" <no-reply@usaprivatemoney.com>' . "\r\n";
$headers .= "MIME-Version: 1.0" . "\r\n";
$headers .= "Content-type: text/html; charset=UTF-8" . "\r\n";


mail( $toadmin, $quotename, $body, $headers );



Example


  if($product_id === 6112) {
 
$customername = $order->get_billing_first_name() .' '.$order->get_billing_last_name();
$message = file_get_contents(WP_CONTENT_DIR . '/themes/twentynineteen-child/emails/premiumsupport.html');
$message = str_replace("{customeremail}",$customername,$message);
$toadmin = $order->get_billing_email();
$quotename = "Let Us Structure Your Partnership";
$headers = 'From: "' . $quotename . '" <no-reply@brrrrinvest.com>' . "\r\n";
$headers .= "MIME-Version: 1.0" . "\r\n";
$headers .= "Content-type: text/html; charset=UTF-8" . "\r\n";

wp_mail( $toadmin, $quotename, $message, $headers );
}

Comments

Popular posts from this blog

How to check date format in PHP?

Check date format in PHP function isCorrectDateFromat($date){     if(!empty($date)){         $dateString = $date; // Replace this with your date string         $format = "Y-m-d"; // Replace this with your expected date format         $dateTime = DateTime::createFromFormat($format, $dateString);         if ($dateTime === false) { /*             echo "The date is not in the correct format."; */         } else {             $errors = DateTime::getLastErrors();             if (empty($errors)) { /*                 echo "The date is in the correct format."; */                 return true;             } else { /*                 echo "...