使用php中的mail()发送带有换行符的电子邮件 [英] Send email with line breaks using mail() in php

查看:483
本文介绍了使用php中的mail()发送带有换行符的电子邮件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用php中的mail()发送电子邮件.我需要格式化消息或至少允许换行符.

I am trying to send email using mail() in php. I need the message to be formatted or at least allow line breaks.

$mail = mail(WEBMASTER_EMAIL, $subject, $message,
 "From: ".$name." <".$email.">/r/n"
 ."Reply-To: ".$email."/r/n"    
 ."X-Mailer: PHP/" . phpversion());

我需要在$ message或/r/n中提供< br/>"标签吗?两者都尝试过,但它们以
或/r/n而不是换行符的形式出现

Do i need to provide "< br/>" tags in the $message or /r/n. Tried both but they came in as
or /r/n and not line breaks

谢谢 普拉迪

推荐答案

是\ r \ n,如反斜杠而不是正斜杠.

It's \r\n, as in backslash not forward slash.

您也可以这样尝试:

$message = "

Hi!

This is one line.

And this is another.



Bye!
";

这篇关于使用php中的mail()发送带有换行符的电子邮件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆