我正在尝试写一封HTML电子邮件,并使用PHP(确切地说是wp_mail
)发送。
它在gmail客户端中运行良好,但如果我在Apple Mail中打开它,我的foreach内容最终会出现在电子邮件的底部,这很不好。
我正在使用$message .= '';
创建电子邮件的消息部分,以添加新的内容。当我到达foreach
时,我这样做:
$message .= '<tr style="padding: 20px 10px; width: 100%; display: inline-block;">
<td valign="top" style="width:100%; display:block;"><table width="100%" border="0" cellspacing="0" cellpadding="0" style="color: #767572; padding: 10px;">
<tr>
<td style="font-family: Helvetica, Arial, sans-serif; line-height: 130%; color: #767572;">';
foreach( $event_query->posts as $post ) : ?>
<?php
$eventlink = get_permalink();
$title = get_the_title();
$message .= '<div class="event clearfix">';
$message .= '<div class="event-image grid-1-4 no-padding">';
$message .= '<h2><a href="'.$eventlink.'">'.$title.'</a></h2>';
?>
在endforeach
之后有更多的内容签署电子邮件。但在Apple Mail上,foreach在邮件结束后才显示。
任何想法?
你没有正确地关闭你的html标签,你应该避免使用div。
$message .= '<tr style="padding: 20px 10px; width: 100%; display: inline-block;">
<td valign="top" style="width:100%; display:block;"><table width="100%" border="0" cellspacing="0" cellpadding="0" style="color: #767572; padding: 10px;">
<tr>
<td style="font-family: Helvetica, Arial, sans-serif; line-height: 130%; color: #767572;">';
foreach( $event_query->posts as $post ) : ?>
<?php
$eventlink = get_permalink();
$title = get_the_title();
$message .= '<div class="event clearfix">';
$message .= '<div class="event-image grid-1-4 no-padding">';
$message .= '<h2><a href="'.$eventlink.'">'.$title.'</a></h2>';
$message .= '</div></div>';
?>
生活和呼吸这个指南- http://www.campaignmonitor.com/resources/will-it-work/guidelines/