我无法打破电子邮件正文的新行。我已经使用了\ n但是我正在接受" \ n"在新行的结果intead
<?php
if ($_SERVER["REQUEST_METHOD"] == "POST")
{
if (isset($_POST['btn_star_subscribe']))
{
$to = "asif.yoosuf@live.com";
$subject = $_POST['subject'];
$message = 'Name:'.$_POST['name'].'/n'.'Mobile:'.$_POST['phone'].'\n'.'Message:'.$_POST['message'];
$header = 'From:'.$_POST['email'];
$retval = mail ($to,$subject,$message,$header);
if( $retval == true )
{
echo "<div class='alert alert-success' id='success-alert'> <button type='button' class='close' data-dismiss='alert'>x</button> <strong>Your request has been sent to our company, They will Contact to shortly</strong> </div>";
}
else
{
echo "<div class='alert alert-success' id='success-alert'> <button type='button' class='close' data-dismiss='alert'>x</button> <strong>Error Sending, Please check your email</strong></div>";
}
}
}
答案 0 :(得分:1)
使用"
打包\n
。使用'
将\
视为文字(不是escape character)。
$message = 'Name:'.$_POST['name']."\n".'Mobile:'.$_POST['phone']."\n".'Message:'.$_POST['message'];
答案 1 :(得分:1)
在双引号中使用\ n而不是单引号 那么它会运作良好
答案 2 :(得分:1)
您可以尝试使用“\ n \ r”而不是“\ n”
答案 3 :(得分:0)
你应该尝试这样的事情:
<?php
if ($_SERVER["REQUEST_METHOD"] == "POST")
{
if (isset($_POST['btn_star_subscribe']))
{
$to = "asif.yoosuf@live.com";
$subject = $_POST['subject'];
$message = 'Name:'.$_POST['name']."<br />";
$message .= 'Mobile:'.$_POST['phone']."<br />";
$message .= 'Message:'.$_POST['message']."<br />";
$header = 'From:'.$_POST['email'];
$retval = mail ($to,$subject,$message,$header);
if( $retval == true )
{
echo "<div class='alert alert-success' id='success-alert'> <button type='button' class='close' data-dismiss='alert'>x</button> <strong>Your request has been sent to our company, They will Contact to shortly</strong> </div>";
}
else
{
echo "<div class='alert alert-success' id='success-alert'> <button type='button' class='close' data-dismiss='alert'>x</button> <strong>Error Sending, Please check your email</strong></div>";
}
}
}