我从数据库中获取用户记录,并且必须逐个向他们发送电子邮件。我的问题是有时在某些电子邮件帐户上成功收到电子邮件,但有时收件人从未收到电子邮件。这种行为对我来说很奇怪。我的PHP代码如下:
while($row = mysqli_fetch_array($result)){
// current Date Time
$now = new DateTime();
$dateTime = $now->format('F j, Y, g:i a');
// generate results email
$name = $row['name'];
$to = $row['email'];
$subject = "subject title";
$header = "from: myname";
$message = "
Date: " . $dateTime . "
Some text.......
";
$sentmail = mail($to,$subject,$message,$header);
if($sentmail){
print_r("Email successfully sent to " . $to . " <br/>");
}
else{
print_r("Error in sending email to " . $to . " . Please re-try <br/>");
}
}
我是否需要调整任何本地smtp配置。 这是php.ini中的 sendmail_path = / usr / sbin / sendmail -t -i