想要在邮件代码中添加模板

时间:2012-05-05 00:55:55

标签: php email templates

我有一个以纯文本形式发送邮件的脚本,我想添加带有table和td的邮件模板 该脚本使用此代码进行消息:

       $body= nl2br('Dear Family and Friends,'.$space."\n\n".' This message is from
 '.$info[0]->first_name.' '.$info[0]->last_name.' who is challenging you to join him 
        at Grow for the Cure to raise money for lung cancer research. '.$space."\n\n".'Have
         you ever wondered what it would be like to see your buddy sport a slick mustache or
         rock some big ol pork chop sideburns? Your friend has courageously provided his face 
        as a blank canvas and put YOU in charge.'.$space."\n".'Grow for the Cure and the Bonnie
     J. Addario Lung Cancer Foundation invite you to click on the link below to see how your
         friend has volunteered to raise money for lung cancer research. Check out his personal
     page where you will be able to see which look is in the lead, and make a donation to your
     favorite choice!'.$space."\n\n".'Your friend needs your support and the research community
     definitely needs your help. Lung cancer kills more people than breast, prostate, colon, 
    liver, kidney, and melanoma cancers combined. Yet, it receives a fraction of 
        the attention and funding. With your help, we are going to change that focus and make
     an impact.'.$space."\n"."All donations go to the Bonnie J. Addario Lung Cancer 
        Foundation and will be used on the front lines of lung cancer research. 
        Your donation WILL make a difference.<p style='color:blue;font-weight:bold;'>"
.$data['glink'].'</p>'.$space."\nHere's what your friend has to say:\n\n".'
     '.$comments."\n\n"."Please visit xyz.org today!\n\nGw  is an affiliate of the\n"."Bonnie\n\n");

如何在此实现我们的html代码? 请告诉我。 谢谢

1 个答案:

答案 0 :(得分:0)

如果我理解你的要求是正确的,你可以这样做:

$body= nl2br('Dear <b>Family</b> and <p style="color:red;">Friends</p>
,'.$space."\n\n".'This message is from '.$info[0]->first_name.' and 
more text here');

请确保反斜杠任何嵌入的双引号或单引号,如

echo "He said \"That's lame!\" or something.";
echo 'He said "That\'s lame!" or something.';