我试图破坏一个变量,我做得对吗?目标是从表中获取所有电子邮件,然后逐个查看。
页面只显示白色。
<?php
ini_set('display_errors',1);
error_reporting(E_ALL);
include_once '../includes/conn.php';
if(!$user->is_loggedin()){
$user->redirect('../users/login.php');
}
$stmt = $conn->prepare("SELECT * FROM newsletter");
$stmt->execute();
while ($userRow = $stmt->fetch(PDO::FETCH_ASSOC)){
$addresses[] = $userRow['email'];
}
$to = implode(",", $addresses);
$subject = "";
$from = "newsletter@epicowl.uk";
$headers "From Epic Owl's Newsletter" . $from;
mail($to, $subject, $message, $headers);
?>
答案 0 :(得分:1)
如果您要发送到整个列表,请唯一地发送每条消息:
<?php
ini_set('display_errors',1);
error_reporting(E_ALL);
include_once '../includes/conn.php';
if(!$user->is_loggedin()){
$user->redirect('../users/login.php');
}
$stmt = $conn->prepare("SELECT * FROM newsletter");
$stmt->execute();
while ($userRow = $stmt->fetch(PDO::FETCH_ASSOC)){
$to = $userRow['email'];
$subject = "";
$from = "newsletter@epicowl.uk";
$headers = "From Epic Owl's Newsletter" . $from;
mail($to, $subject, $message, $headers);
}
?>
此外,如果您的MTA有限制,您可以错开发送。例如,如果限制为500 /小时,则发送100/15分钟。这将确保您不超过限制。我希望你也有选择退出,你的清单是双重验证。欢迎成为潜在的垃圾邮件发送者。