【问题标题】:HTML email is not working in table formatHTML 电子邮件不适用于表格格式
【发布时间】:2025-12-01 03:00:01
【问题描述】:

我在 HTML 电子邮件内容中使用表格格式,但它无法发送电子邮件。 那么谁能告诉我如何使用 PHP 发送表格格式的电子邮件?

【问题讨论】:

    标签: php wordpress email


    【解决方案1】:

    您好,请检查您的wp_mail返回值。

    $message = '<table>
                    <tr>
                        <td>Name</td><td>'.$name.'</td></tr>
                        <tr><td>Lead Person Name</td><td>'.$pname.'</td></tr>
                        <tr><td>Tour Date</td><td>'.$date.'</td></tr>
                        <tr><td>No. Of Pax</td><td>'.$person.'</td>
                    </tr>
              </table>';
    
    $to = 'email@gmail.com';
    $subject = 'HTML Formate mail';
    $body = $message;
    $headers = array('Content-Type: text/html; charset=UTF-8');
    
    $send_status = wp_mail( $to, $subject, $body, $headers );
    
    if($send_status)
     echo 'Mail Send Successfully';
    else
     echo 'Something went wrong';
    

    希望对你有所帮助。

    【讨论】:

      【解决方案2】:
       $data = "<table><tr><td>Name</td><td>".$name."</td></tr>
                          <tr><td>Lead Person Name</td><td>".$pname."</td></tr>
                          <tr><td>Tour Date</td><td>".$date."</td></tr>
                          <tr><td>No. Of Pax</td><td>".$person."</td></tr>
                  </table>";
      
      $subject = 'HTML Formate mail';
      $body = $data;
      $headers = 'Content-Type: text/html; charset=UTF-8';
      
      wp_mail('email@gmail.com', $subject, $body, $headers ); 
      

      【讨论】: