无法使用phpmailer发送邮件。在phpmailer的bodypart中编写脚本并更改了isHTML(flase)如何以正确的格式进行操作,请指导

时间:2018-07-09 10:12:24

标签: php phpmailer synapse teamsql

应该使用哪种类型的phpmailer发送邮件,我们可以在phpmailer正文部分中使用php脚本吗,例如:$mail->Body"here";?帮助我被困在phpmailer正文部分,我无法从数据库获取值并更改了isHTML(false)。

显示错误 该页面无法正常运行www.xyz.com目前无法处理此请求。 HTTP ERROR 500就是错误。

<?php

     include ('connection/dbconnect.php'); 
  use PHPMailer\PHPMailer\PHPMailer;

  if(isset($_POST['submitemail'])) {

 $sql = "SELECT * from enquiry where DATE(update_time) =CURDATE() and customer_id='agent1'";
    $result = $conn->query($sql);
include_once "PHPMailer/PHPMailer.php";

            $mail = new PHPMailer();
            $mail->setFrom('alxxxxxxxxxxxxx@gmail.com',$uname);
            $mail->addAddress('amxxxxxxxxxxx@gmail.com');
            $mail->Subject = "'Today Final Report', $uid";
            $mail->isHTML(false);
            $mail->Body = 
             '<table>
            <tr>
            <th>AgentID</th>
            <th>StudentName</th>
            <th>Course</th>
            <th>Location</th>
            <th>Date</th>
            </tr>';
                  if ($result->num_rows >0) {
                      $row1 = "";
                   while($row = $result->fetch_assoc()) {
                       $cd = $row['locations']; 
                       $cd.= $row['update_time'];
                       $cd.= $row['coursename']; 
                       $cd.= $row['name']; 

echo '<tr>
      <td>' . $row["customer_id"]. '</td><td>' . $row["name"]. '</td>
      <td>' . $row["coursename"]. '</td>
      <td>' . $row["locations"]. ' <td>' . $row["update_time"]. '</td>
      </tr>';
               }   
          echo '</table>'; 
          } else {
         echo '0 results';
      } ;


            if ($mail->send())
                $msg = "You have been registered! Please verify your email!";
            else
                $msg = "Something wrong happened! Please try again!";  


if (mysqli_query($conn,$sql)) {
    echo "<script> alert('submitted thank you $uname')
                   window.location.href='submitreport.php';
    </script>";
                            }
}
  else {

        echo "<script> alert('Please login to proceed');</script>";
        //header('location:login.php');
        ?>
        <script type="text/javascript">
     window.location.href = 'index.php';
     </script>

    <?php }


    ?>

0 个答案:

没有答案