1

我正在尝试编写 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 会在电子邮件结束后显示。

有任何想法吗?

4

1 回答 1

1

你没有为初学者正确关闭你的 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/

于 2014-05-26T13:49:57.067 回答