繁体   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