所以我一直在做一个项目,我有一个功能可以向被选中雇主的员工发送电子邮件。现在,除了邮件功能(我正在使用 winhost,我们需要包含 Mail.php 才能使邮件功能正常工作)之外,它正在工作。它有时会发送 3 封电子邮件而不是 2 封,有时会发送 1 封电子邮件而不是 2 封。
编码 :
if (isset($_POST['openemailmem'])){
$memberuser = $_POST['openemailmemusername'];
$sql = "SELECT email, username, password, status FROM csvdata WHERE memberview =:user ";
$getinfo=$DBH->prepare($sql);
$getinfo->execute(array(':user' => $memberuser));
while ($row = $getinfo->fetch(PDO::FETCH_ASSOC)) {
$check = $row;
$newEmployeeEmail = $check['email'];
$csvusername = $check['username'];
$password = $check['password'];
$status = $check['status'];
if ($status == "Open"){
echo "tesing";
$from = "the email of where it is coming from is here but i removed";
$to = $newEmployeeEmail;
if (!empty($_POST['cc'])){
$cc = $_POST['cc'];
}
if (!empty($_POST['ccsend'])){
$cc = $_POST['ccsend'];
$to .= ", $cc";
}
$subject = "removed msg";
$body = "removed msg";
$host = "i removed";
$username = "i removed";
$password = "i removed";
$headers = array ('From' => $from, 'To' => $to,'Cc' => $cc, 'Subject' => $subject);
$smtp = Mail::factory('smtp', array ('host' => $host, 'auth' => true, 'username' => $username, 'password' => $password));
$mail = $smtp->send($to, $headers, $body);
}
}
header("Location: I removed this.php?getmsg=12");
exit;
}
谢谢你所有的时间!!!