[英]foreach in HTML E-Mail breaks in Apple Mail
I'm trying to write a HTML e-mail and fire it off with PHP ( wp_mail
to be exact). 我正在尝试编写HTML电子邮件,并用PHP( wp_mail
是wp_mail
将其wp_mail
。
It works fine in the gmail client, but if I open it up in Apple Mail, my foreach content ends up at the bottom of the e-mail, which is no good. 它在gmail客户端中可以正常工作,但是如果我在Apple Mail中打开它,我的foreach内容将最终显示在电子邮件的底部,这是不好的。
I'm creating the message part of the e-mail using $message .= '';
我正在使用$message .= '';
创建电子邮件的消息部分$message .= '';
to add new bits of content. 添加新的内容。 When I get to the foreach
I'm doing this: 当我进入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>';
?>
After the endforeach
there is more content signing the e-mail off. 后endforeach
有更多的内容签署电子邮件了。 But on Apple Mail the foreach shows after the end of the e-mail. 但是在Apple Mail上,电子邮件结束后显示了foreach。
Any ideas? 有任何想法吗?
You're not closing your html tags properly for starters and you should avoid using divs. 您没有正确地为初学者关闭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>';
?>
Live and breathe this guide - http://www.campaignmonitor.com/resources/will-it-work/guidelines/ 生活和呼吸本指南-http: //www.campaignmonitor.com/resources/will-it-work/guidelines/
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.