将收件人添加到wp_mail()不起作用吗?

时间:2017-01-18 作者:KatS

我真的在这件事上大发雷霆。为什么它不会发送?我觉得有点$recipient 来自$var 我没有得到的价值。相同的行项目用于创建帖子,这很有效,所以我不认为是它们。任何帮助都将不胜感激。

function ecard_email_send(){
$sitename = get_bloginfo(\'name\');
$siteurl = site_url();
$cardurl = ($siteurl . \'/\' . $post_title);
$recipient = esc_attr($lineItem[\'recipient_email\']);
$headers = array(\'Content-Type: text/html; charset=UTF-8\');
$subject = ($lineItem[\'sender_name\'] . \' has sent you an Ecard from \' . $sitename);
$sitename = get_bloginfo(\'name\');
$siteurl = site_url();
$cardurl = ($siteurl . \'/\' . $post_title);

$content = array(
\'name\' => $lineItem[\'recipient_name\'],
\'verse\' => $lineItem[\'ecard_message\'],
\'greeting\' => $lineItem[\'ecard_greeting\'],
\'closing\' => $lineItem[\'ecard_closing\'],
\'sender\' => $lineItem[\'sender_name\'],
\'image\' => $ecardbackground[0],
\'link\' => $cardurl,
\'value\' => \'View your card online\'
) ;
 ob_start();
 include(MY_PLUGIN_PATH . \'/templates/ecard_email.php\');
                $message = ob_get_contents();
            ob_end_clean();


$status = wp_mail( $recipient, $subject, $message, $headers );
exit();
 }
这是我的模板编辑-或者可能不是格式不对:

<?php /*email template tester */
echo </pre>
!doctype html
body
div
table role="presentation" align="center" border="0" cellpadding="0" cellspacing="0" width="100%"
tr
td valign="middle" style="text-align: center; padding: 40px; font-family: sans-serif; font-size: 15px; mso-height-rule: exactly; line-height: 20px; color: #ffffff;"
`\'.$content[\'verse\'].\'`
/td
/tr
tr
td valign="middle" style="text-align: center; padding: 40px; font-family: sans-serif; font-size: 15px; mso-height-rule: exactly; line-height: 20px; color: #ffffff;"
`\'.$content[\'closing\'].\'`
</td>
</tr><tr>
<td valign="middle" style="text-align: center; padding: 40px; font-family: sans-serif; font-size: 15px; mso-height-rule: exactly; line-height: 20px; color: #ffffff;">
\'.$content[\'closing\'].\'
/td>
/tr
/table
/div
/body
/html `\';`
?>

1 个回复
SO网友:Umer Shoukat

似乎您在中使用的变量名称不正确

$status = wp_mail( $ecard_recipient, $subject, $message, $headers );
您在中收到收件人的电子邮件$recipient 在wp\\u mail()函数中,您正在为收件人电子邮件传递另一个变量。所以,我想这一定是你得到空变量的问题。

相关推荐