简体   繁体   中英

Insert HTML Email Template in PHP

Can someone please help me understand what the problem is. I have tried several times to get it to function properly, but no success. I am trying to insert my HTML email template into a php file that generates an automated email response for registration to my site.

Here is the file:

function simplr_send_notifications($atts, $data, $passw) {
$site = get_option('siteurl');
$name = get_option('blogname');
$user_name = @$data['username'];
$email = @$data['email'];
$notify = @$atts['notify'];
$emessage = apply_filters('simplr_email_confirmation_message');
$message = <<<EOF 
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">

   I cut out the bulk of the template to save space...
        </table>
    </center>
</body>
</html>
EOF;
$headers = "From: $name" . ' <' .get_option('admin_email') .'> ' ."\r\n\\";
wp_mail($notify, "A new user registered for $name", "A new user has registered for $name.\rUsername: $user_name\r Email: $email \r",$headers);
$emessage = $emessage . "\r\r---\r";
    if(!isset($data['password'])) {
        $emessage .= "You should login and change your password as soon as possible.\r\r";
    }
$emessage .= "Username: $user_name\r";
$emessage .= (isset($data['fbuser_id']))?'Registered with Facebook':"Password: $passw\rLogin: $site/wp-login.php";
wp_mail($data['email'],"$name - Registration Confirmation", $emessage, $headers);

Any help is appreciated! Thanks.

try this

<?php



            $template_text=addslashes('<table background="http://www.saptatec.com/shivusapta/ram/livesearch1/kcr.gif;"><tr><tr><th background="http://www.saptatec.com/shivusapta/ram/livesearch1/kcr.gif">mail</th></tr><tr><tr><th>email</th></tr> <tr><tr><th>gmail</th></tr><tr><td><img src="http://www.saptatec.com/shivusapta/ram/livesearch1/kcr.jpg" alt="baba"" /></td> </tr></table>');

            eval("\$body=\"$template_text\";");

            $header="Content-type:text/html \r\n";
            $header.="From: From Name <noreply@yourweb.com> \r\n";

            mail("yiy143@gmail.com","Activate Your Account",$body,$header);
?>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM