我有这段代码:
<?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
}
?>
然而,它甚至根本不向我发送电子邮件。我不确定该怎么做或如何解决它。提前谢谢!
答案 0 :(得分:0)
首先,尝试从email()
PHP函数测试布尔返回值,看看是否至少接受了邮件传递...
然后,您可以进一步调查......