-1

我有一个以纯文本形式发送邮件的脚本,我想添加带有表格的邮件模板,并且 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 代码?请告诉我。谢谢

4

1 回答 1

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.';
于 2012-05-05T01:20:42.053 回答