下面的代码不发送任何电子邮件,已经在phpmyadmin中尝试了sql代码,我得到了正确的结果。得到四行,并且每个人在userMail下都有一个有效的邮件。有人能发现我做错了吗?邮件的原始发送已更改为XXX@XXX.XX
我在服务器上的代码中使用邮件,并且邮件可以正常工作,并且邮件功能具有正确的配置。
$firstPremission = 5;
$secondPremission = 6;
$sql = "SELECT * FROM user WHERE permission = ? OR permission = ?";
$stmt = mysqli_stmt_init($conn);
if(!mysqli_stmt_prepare($stmt, $sql)){
header("Location: ../signup.php?error=sqlerror");
exit();
}else{
mysqli_stmt_bind_param($stmt, 'ii', $firstPremission, $secondPremission);
mysqli_stmt_execute($stmt);
$userResult = mysqli_stmt_get_result($stmt);
if(mysqli_num_rows($userResult) > 0){
while($userRow = mysqli_fetch_assoc($userResult)){
$userMail = $userRow['userMail'];
$msg = "Ny använder är registrerad";
// use wordwrap() if lines are longer than 70 characters
$msg = wordwrap($msg,70);
$headers = 'From: XXX@XXX.XX' . "\r\n" .
'Reply-To: XXX@XXX.XX' . "\r\n" .
'X-Mailer: PHP/' . phpversion();
mail($userMail,'New account',$msg,$headers);
}
}
}