Php 要在邮件代码中添加模板吗

Php 要在邮件代码中添加模板吗,php,email,templates,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

我有一个用纯文本发送邮件的脚本,我想用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");
$body=nl2br('亲爱的家人和朋友,'.$space.'.\n\n'.'此消息来自
“.$info[0]->名字。”.$info[0]->姓。“谁在挑战你加入他?”
在Grow for the Cure为肺癌研究筹集资金。..$space.\n\n.“'Have”
你有没有想过看到你的朋友留着光滑的胡子或者
摇一些大猪排鬓角?你的朋友勇敢地提供了他的脸
作为一块空白画布,让你负责...$space.\n.“为治疗和邦妮成长”
J.Addiao肺癌基金会邀请你点击下面的链接看看你的
这位朋友自愿为肺癌研究筹集资金。看看他的个人资料
页面中,您将能够看到哪个外观处于领先地位,并向您的客户捐款
最喜欢的选择!。$space。“\n\n”。'您的朋友需要您的支持和研究社区
当然需要你的帮助。肺癌比乳腺癌、前列腺癌、结肠癌致死的人数还要多,
肝脏、肾脏和黑色素瘤癌症合并在一起。然而,它只接受了一小部分的治疗
关注和资金。在你的帮助下,我们将改变这一关注点,并取得成功
影响....$space.\n.“所有捐款都将捐给Bonnie J.Addario肺癌研究所
基础和将用于肺癌研究的前线。
您的捐赠将有所不同。

“ .$data['glink'].

'.$space.\n您的朋友会这么说:\n\n“ “.$comments.”\n\n“.”请今天访问xyz.org!\n\nGw是“.Bonnie\n\n”的附属公司;
我如何在这种情况下实现我们的html代码? 请让我知道。
谢谢

如果我正确理解您的要求,您可以简单地执行以下操作:

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

不要在电子邮件中使用表格。这个邮件内容在home.php中,我不会在任何mail client.Hmmm中使用。您的问题是如何在邮件中使用html标记吗?是的,在php文件中,我在这里发布了用于邮件的代码。如果您自己构建html邮件,则在php中发送html邮件是很棘手的。使用PHPMailer或Swiftmailer发送MIME消息要容易得多。@Amit,如果回答了您的问题,您可以选中“正确答案”复选标记。我们在这里就是这样做的。:)我想在那里使用这种类型的html代码(我删除了一些太长的部分案例,无法在这里发布):亲爱的
这条消息。。。嗯,有什么问题吗?想做就做
echo "He said \"That's lame!\" or something.";
echo 'He said "That\'s lame!" or something.';