PHP mail line break problem

前端 未结 4 1625
执笔经年
执笔经年 2021-01-20 18:46

I want to format content of the mail to show the content in different line. here is my message contetn. bu the \\n and \\r is not working in this case. it just shows all the

相关标签:
4条回答
  • 2021-01-20 18:56

    You're telling the email client the message is HTML, so the CR LF combination will be treated like any other whitespace.

    To fix this, change the content type to show you are sending a plain text email

    $headers .= "Content-Type: text/plain; charset=\"iso-8859-1\"".$eol;
    

    Alternatively, turn your message into an HTML message - an easy way to do that in your case would be to run it through nl2br to turn the newlines into <br> tags

    0 讨论(0)
  • 2021-01-20 19:06

    For \n to work it needs to be double quotes, not single. "\n" is the right thing, '\n' is wrong and will not work.

    0 讨论(0)
  • 2021-01-20 19:20

    Your content type is HTML so you should use br or p tags instead of line feeds

    0 讨论(0)
  • 2021-01-20 19:23

    Yep you've got Content-Type: text/html, so the CR LF is being treated like whitespace. Either send it as Content-Type: text/plain or call nl2br on your contents.

    0 讨论(0)
提交回复
热议问题