douhao123457 2012-01-08 22:52
浏览 28
已采纳

在PHP邮件功能的$体系中创建一个新行

I've got the PHP mail(): function working for a form I'm using on my site. I am now trying to format the $body attribute to look nicer and more organized when I receive the subsequent e-mail.

I've tried and I've tried
and both give me

Here's the snippet of the code that I'm working with (I think it's just a matter of syntax that I'm doing wrong):

if(!empty($brandname) && !empty($firstname) && !empty($lastname) && !empty($email) && !empty($goals) && !empty($bio)){
        $to = 'test@test.com';
        $subject = 'Submission Form';
        $body = 'Brand Name: '.$brandname.'<br />Name: '.$firstname.' '.$lastname.'<br />Email: '.$email.'<br />About the Company:'.$bio;
        $headers = 'From: '.$email;

It's just displayed the <br /> as text in the e-mail I receive. It was the same when I used (which I'm assuming is actually the right way to do it). What am I doing wrong? Thanks.

  • 写回答

6条回答 默认 最新

  • dtef9322 2012-01-08 22:58
    关注

    You must place in double quotes " not between single quotes ' If you want that this sequence would be interpreted as a new line (line feed 0x0A) character

    Take a look at this php documentation:

    http://php.net/manual/en/language.types.string.php

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(5条)

报告相同问题?

悬赏问题

  • ¥15 写一个方法checkPerson,入参实体类Person,出参布尔值
  • ¥15 我想咨询一下路面纹理三维点云数据处理的一些问题,上传的坐标文件里是怎么对无序点进行编号的,以及xy坐标在处理的时候是进行整体模型分片处理的吗
  • ¥15 CSAPPattacklab
  • ¥15 一直显示正在等待HID—ISP
  • ¥15 Python turtle 画图
  • ¥15 关于大棚监测的pcb板设计
  • ¥15 stm32开发clion时遇到的编译问题
  • ¥15 lna设计 源简并电感型共源放大器
  • ¥15 如何用Labview在myRIO上做LCD显示?(语言-开发语言)
  • ¥15 Vue3地图和异步函数使用