在PHP中插入HTML电子邮件模板

时间:2012-10-11 23:30:57

标签: php html email templates

有人可以帮我理解问题所在。我已经多次尝试让它正常运行,但没有成功。我正在尝试将我的HTML电子邮件模板插入到php文件中,该文件生成一个自动电子邮件响应以注册到我的网站。

这是文件:

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);

任何帮助表示赞赏!感谢。

1 个答案:

答案 0 :(得分:-1)

试试这个

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