Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/html/87.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 未在电子邮件中呈现HTML $message='说“不”还有什么好处你能想到?-'$_张贴[“其他福利”]。'“。 “你保证要做什么?”——$_发布[“什么承诺”]。' ",;_Php_Html - Fatal编程技术网

Php 未在电子邮件中呈现HTML $message='说“不”还有什么好处你能想到?-'$_张贴[“其他福利”]。'“。 “你保证要做什么?”——$_发布[“什么承诺”]。' ",;

Php 未在电子邮件中呈现HTML $message='说“不”还有什么好处你能想到?-'$_张贴[“其他福利”]。'“。 “你保证要做什么?”——$_发布[“什么承诺”]。' ",;,php,html,Php,Html,我试图在php中的每一行之后做一个中断,但是使用嵌入的HTML。当我发送电子邮件时(功能不包括在内),它不会以中断方式呈现。它实际上只是将键入一个字符串。是否有办法更正此问题?要发送包含html的电子邮件,请特别注意以下标题: $message = 'What are the other benefits to saying "nah" that you can think of? - ' . $_POST['other-benefits'] . '<br>' . 'W

我试图在php中的每一行之后做一个中断,但是使用嵌入的HTML。当我发送电子邮件时(功能不包括在内),它不会以中断方式呈现。它实际上只是将
键入一个字符串。是否有办法更正此问题?

要发送包含html的电子邮件,请特别注意以下标题:

$message = 'What are the other benefits to saying "nah" that you can think of? - ' . $_POST['other-benefits'] . '<br>' .
       'What are you pledging to do? - ' . $_POST['what-pledge'] . '</p>';

示例代码:

$headers .= "MIME-Version: 1.0\r\n";
$headers .= "Content-Type: text/html; charset=ISO-8859-1\r\n";
$otherbenefits=$\u POST['other-benefits'];
$whatpledge=$_POST['what-质押];

$email=由于缺少关于该问题的信息,我只能假设问题在于电子邮件的标题没有设置为发送HTML电子邮件

您必须按照以下思路做一些事情:

$otherbenefits = $_POST['other-benefits'];
$whatpledge = $_POST['what-pledge'];

$email = <<< LOL
<html> 
  <body> 
    <p> What are the other benefits to saying "nah" that you can think of? - $otherbenefits <br>  What are you pledging to do? - $whatpledge </p>
  </body>
</html>
LOL;

$emailaddress = "personsemail@website.com";
$subject = "Test Email";
$headers = "From: noreply@server.com\r\n";
$headers .= "MIME-Version: 1.0\r\n";
$headers .= "Content-Type: text/html; charset=ISO-8859-1\r\n";


mail($emailaddress, $subject, $email, $headers);
//设置电子邮件内容。
$to=”example@email.com";
$subject=“示例HTML电子邮件”;
$message='说“不”还有什么好处你能想到?-'$_张贴[“其他福利”]。'
“。 “你保证要做什么?”——$_发布[“什么承诺”]。'

",; //设置标题。 $headers=“From:from@email.com\r\n“; $headers.=“回复:replyto@email.com\r\n“; $headers.=“抄送:susan@example.com\r\n“; $headers.=“MIME版本:1.0\r\n”; //下一个就是魔法发生的地方。 $headers.=“内容类型:text/html;字符集=ISO-8859-1\r\n”; //发送! 邮件($to、$subject、$message、$headers);

请参阅:

-没有足够的代码来支持此问题。“我发送了一封电子邮件,功能未包含”最重要的部分…只是将其呈现为错误,这是我提供的代码。邮件功能正常工作。在打开PHP标记后立即将错误报告添加到文件顶部,例如
。。。然而,呈现通常由电子邮件头控制,这是函数调用的一部分。请显示更多代码。你能评论一下否决票吗?这是我用来发送包含html的电子邮件的代码,它工作正常。不是我的反对票,但我知道这种感觉。带有“jam”的会。@Fred ii-谢谢您的编辑,它总是有用的,因为它可以链接到有问题的函数。
// Setup email content.
$to = "example@email.com";
$subject = "Example HTML email";

$message = 'What are the other benefits to saying "nah" that you can think of? - ' . $_POST['other-benefits'] . '<br>' .
       'What are you pledging to do? - ' . $_POST['what-pledge'] . '</p>';

// Setup headers.
$headers = "From: from@email.com\r\n";
$headers .= "Reply-To: replyto@email.com\r\n";
$headers .= "CC: susan@example.com\r\n";
$headers .= "MIME-Version: 1.0\r\n";

// This next one is where the magic happens.
$headers .= "Content-Type: text/html; charset=ISO-8859-1\r\n";

// Send!
mail($to, $subject, $message, $headers);