簡體   English   中英

使用php自動發送外觀相同的電子郵件

[英]Send email automatically with same appearance using php

我有以下代碼:

<?php 
error_reporting(E_ALL);
ini_set('display_errors' ,1);
require "connection.php";
    $query= "SELECT client_id, count(client_id) AS rows, array_agg(insurance) AS insurance from vouchers WHERE parsing_date=CURRENT_DATE GROUP BY client_id";
    $result = pg_query($conn,$query);

    ?>

    <!DOCTYPE html>
    <html>
    <head>
    <link href="//netdna.bootstrapcdn.com/bootstrap/3.0.3/css/bootstrap.min.css" rel="stylesheet">
    <link href = "http://fonts.googleapis.com/css?family=Roboto:400">
    <style>
    .responstable {
      margin: 1em 0;
      width: 100%;
      overflow: hidden;
      background: #FFF;
      color: #024457;
      border-radius: 10px;
      border: 1px solid #167F92;
      word-wrap: break-word;
    }
    </style>
    </head>
    <body>
    <div class="container-fluid">
            <div>

              <h1>Clients</h1>


            </div>

    <table class="responstable" rules='all' style='border-collapse: collapse;'>
    <thead>
        <tr>
            <th>Client id</th>
            <th>Number of rows</th>
            <th>Insurance</th>

        </tr>
    </thead>
      <?php 
        while($row = pg_fetch_array($result))
        { 
    $find ='{';
    $replace = '' ;
    $arr = $row['insurance'];
    $insurance3= str_replace($find,$replace,$arr);
    $insurance = str_replace('"','  ',$insurance3);

      ?>

      <tbody>


         <td><?php echo $row['client_id']; ?></td>
         <td><?php echo $row['rows'];?></td>   
         <td><?php echo $insurance; ?></td> 

        </tr>
      <?php  }


      ?>  </tbody>
    </table>


</div>

</body>
</html>

此代碼顯示ID,行和保險的報告; 我希望它能夠每天自動向我發送一封電子郵件,郵件的內容和樣式與表中顯示的相同。 我嘗試了這個:

<?php

require "connection.php";


  if (isset($_REQUEST['email']))  {


  $admin_email = "admin@hotmail.com";
  $email = "jasmine@hotmail.com";  //my email
  $subject = 'Date';

  //send email
  mail($admin_email, "$subject", $comment, "From:" . $email);



  //if "email" variable is not filled out, display the form

?>
<?php
$query= "SELECT client_id, count(client_id) AS rows, array_agg(insurance) AS insurance from vouchers WHERE parsing_date=CURRENT_DATE GROUP BY client_id";
$result = pg_query($conn,$query);

?>

<!DOCTYPE html>
<html>
<head>
<link href="//netdna.bootstrapcdn.com/bootstrap/3.0.3/css/bootstrap.min.css" rel="stylesheet">
<link href = "http://fonts.googleapis.com/css?family=Roboto:400">

<style>
.responstable {
  margin: 1em 0;
  width: 100%;
  overflow: hidden;
  background: #FFF;
  color: #024457;
  border-radius: 10px;
  border: 1px solid #167F92;
  word-wrap: break-word;
}
</style>

</head>

<body>
<div class="container-fluid">
        <div>

          <h1>Clients</h1>


        </div>

<table class="responstable" rules='all' style='border-collapse: collapse;'>
<thead>
    <tr>
        <th>Client id</th>
        <th>Number of rows</th>
        <th>Insurance</th>

    </tr>
</thead>
  <?php 
    while($row = pg_fetch_array($result))
    { 

$find ='{';
$replace = '' ;
$arr = $row['insurance'];
$insurance3= str_replace($find,$replace,$arr);
$insurance = str_replace('"','  ',$insurance3);

  ?>

  <tbody>


     <td><?php echo $row['client_id']; ?></td>
     <td><?php echo $row['rows'];?></td>   
     <td><?php echo $insurance; ?></td> 

    </tr>
  <?php  }


  ?>  </tbody>
</table>

</div>

</body>
</html>

<?php
  }
?>

但是,它甚至根本沒有給我發送電子郵件。 我不確定該怎么做或如何解決它。 提前致謝!

首先,請嘗試從email() PHP函數測試布爾返回值,以查看是否至少接受了郵件傳遞...
然后,您可以進一步調查...

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM