【问题标题】:PHP formatted email doesn't send PHP codePHP 格式的电子邮件不发送 PHP 代码
【发布时间】:2017-02-16 10:12:12
【问题描述】:

我正在尝试通过 PHP 格式的电子邮件向客户发送个性化消息,其中包含一些 PHP 代码。但是,由于某些惊人的原因,我无法发送$_POST['message']。但其他变量已发送且可见。

这是我的 PHP 代码:

<?php
function set_html_content_type() {
    return 'text/html';
}

add_filter( 'wp_mail_content_type', 'set_html_content_type' );

$to = $_POST['email'];
$subject = 'Whittington Barge - QR';
$body = '<html><head></head><body>
<h1>Here is your Voucher!</h1>
<h3>Test personalized message: '.$_POST['message'].'<h3>
<p>Feel free to save it to your phone and show us when you arrive!</p>
<img src="'.$_POST['image'].'"></img></body></html>';

wp_mail( $to, $subject, $body );

remove_filter( 'wp_mail_content_type', 'set_html_content_type' );
?>

结果,我得到this e-mail

我已经尝试了几乎所有我知道的东西。它也在 Wordpress 网站上举行。

【问题讨论】:

  • 关闭你的h3标签,把&lt;h3&gt;Test personalized message: '.$_POST['message'].'&lt;h3&gt;改成&lt;h3&gt;Test personalized message: '.$_POST['message'].'&lt;/h3&gt;

标签: php wordpress email


【解决方案1】:

&lt;h3&gt; 标签已打开/未关闭。

关闭你的&lt;h3&gt;标签,

改变: &lt;h3&gt;Test personalized message: '.$_POST['message'].'&lt;h3&gt;

收件人:&lt;h3&gt;Test personalized message: '.$_POST['message'].'&lt;/h3&gt;

【讨论】:

  • 它甚至不发送&lt;h3&gt; 字符串...可能是什么问题?
  • 您是否进行了建议的更改?
  • 您能否在发送邮件之前回显/打印出$body 变量?
  • 那么$_POST['message']的值是多少?
  • 它会回显完整的消息,但不会只发送一行电子邮件。难道是因为缓存?目前的值为 TEST MESSAGE,但它可以是任何值
猜你喜欢
  • 1970-01-01
  • 2016-12-06
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2014-08-17
  • 2011-09-16
相关资源
最近更新 更多