我对PHPMailler有问题,我找不到解决方法。如果您有帮助,我会很高兴。
$GuvenlikTakipsor=$pdo->prepare("SELECT * FROM GuvenlikTakip ORDER BY InDate DESC, InTimeDESC", array(PDO::ATTR_CURSOR => PDO::CURSOR_SCROLL));
$GuvenlikTakipsor->execute();
$OBody='<!DOCTYPE html><html><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8"><meta charset="utf-8"></head><body>';
$OBody.='<table border="1"><th>Adı Soyadı</th><th>Giriş Tarih-Saat</th><th>Çıkış Tarih-Saat</th></tr>';
while ($GuvenlikTakipcek=$GuvenlikTakipsor->fetch(PDO::FETCH_ASSOC)) {
$OBody.= '<tr><td>'.$GuvenlikTakipcek['YAdSoyad'].'</td>';$OBody.='<td>'.$GetGirisTarih.' - '.$GuvenlikTakipcek['GirisSaat'].'</td>';
$OBody.='<td>'.$GetCikisTarih.' - '.$GuvenlikTakipcek['CikisSaat'].'</td>';
$OBody.='</tr>';
}
$OBody.='</table></body></html>';
结果输出如下。
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta charset="utf-8">
</head>
<body>
<table border="1">
<th>Stuff Name</th>
<th>In Date-Time</th>
<th>Out Date-Time</th>
</tr>
<tr>
<td>John Doe</td>
<td>03.03.2020 - 09:29</td>
<td>03.03.2020 - 17:36</td>
</tr>
<tr>
<td>Marilyn Monroe</td>
<td>03.03.2020 - 08:54</td>
<td>03.03.2020 - 18:22</td>
</tr>
<tr>
<td>Bruce Willis</td>
<td>03.03.2020 - 08:30</td>
<td>03.03.2020 - 18:04</td>
</tr>
</table>
</body>
</html>
$mail = new PHPMailer();
$mail->IsSMTP();
$mail->SMTPAuth = true;
$mail->Host = $MailSmtpHost;
$mail->Port = 25;
$mail->Username = $MailUserName;
$mail->Password = $MailPassword;
$mail->SetFrom($mail->Username, 'My Name');
$mail->AddAddress("$MailKimeGidecek", 'MosCom');
$mail->CharSet = 'UTF-8';
$mail->Subject = $_POST['MailSubject'];
$mail->MsgHTML($OBody);
if($mail->Send()) {
echo '<script>alert("Mail Sent!");</script>';
} else {echo 'An Error Occurred: ' . $mail->ErrorInfo;}
传入邮件的输出如下。
<!DOCTYPE html>
<html>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta charset="utf-8">
<head>
</head>
<body>
<table border="1">
<th>Stuff Name</th>
<th>In Date-Time</th>
<th>Out Date-Time</th>
</tr>
</table>
</body>
</html>
我检查了$ OBody变量,但是没有看到任何问题。就像我在上面给出的第一个HTML记录一样,输出内容。
看起来您好像错过了第一个<tr>
<body>
<table border="1">
<th>Stuff Name</th>
<th>In Date-Time</th>
<th>Out Date-Time</th>
</tr>
将相关变量分配给文本区域,并将值POST添加到
<textarea type="text" class="form-control" rows="20" maxlength="1000" name="Body"><?php echo $OBody?></textarea>
$mail->MsgHTML($_POST['Body']);
它已更新。