Send email with a template using php

后端 未结 9 2184
南旧
南旧 2020-12-04 07:45

How can I send an email using php then add a template design in the email? I\'m using this:

$to = \"someone@example.com\";  
$subject = \"Test mail\";  
$mes         


        
9条回答
  •  予麋鹿
    予麋鹿 (楼主)
    2020-12-04 08:06

            $message_to_client = file_get_contents("client_email.html");
            //$message_to_client = "bla bla {{ EMAIL }} bla bla";
    
    
            $variables = array(
                'SITE_TITLE' => $SITE_TITLE,
                'SITE_LOGO' => $SITE_LOGO,
                'SITE_URL' => $SITE_URL,
                'CLIENT_NAME' => strip_tags($data->clientname),
                'PHONE' => strip_tags($data->phone),
                'EMAIL' => strip_tags($data->email),
                'CITY' => strip_tags($data->city),
                'REGION' => strip_tags($data->region),
                'COMMENT' => htmlentities($data->comment)                
            );
    
            $message_to_client = preg_replace_callback('/{{([a-zA-Z0-9\_\-]*?)}}/i',
                 function($match) use ($variables) { 
                     return  $variables[$match[1]]; 
            }, $message_to_client );
    

提交回复
热议问题