phpMailer lib を使用して、通知メールをユーザーに送信する関数を作成しています。
public function notify($address,$subject = '',$body = null,$mailer_options = array()) {
try {
$phpmailer = new PHPMailer($exceptions = true);
$phpmailer->CharSet = 'UTF-8';
$phpmailer->IsSMTP();
$phpmailer->SMTPAuth = true;
$phpmailer->SMTPKeepAlive = true;
//$phpmailer->SMTPDebug = true;
$phpmailer->IsHTML(true);
$phpmailer->Host = ...
$phpmailer->Username = ...
$phpmailer->Password = ...
$phpmailer->From = ...
$phpmailer->FromName =...
$phpmailer->AddAddress($address);
$phpmailer->Subject = $subject;
$phpmailer->Body = $body;
$phpmailer->Send();
$phpmailer->ClearAllRecipients();
}
クラス内でメールを送信するか、複数のメールを送信するだけで問題なく動作します。しかし、もしそうなら
for($i=0;$i<3;$++)
{
$notification = new $Notification();
$notification->notify(...);
}
空白のページを返します。エラーもメッセージも何もありません。あなたが尋ねる前に、私はdisplay_errorsをオンにしています。
それは何でしょうか?
次のような phpmailer のインスタンスが 1 つだけあれば、問題なく動作します。
$phpmailer = new PHPMailer($exceptions = true);
(...)
for($i=0;$i<3;$i++)
{
$phpmailer->AddAddress('address');
$phpmailer->Subject = "";
$phpmailer->Body = "sasa";
$phpmailer->Send();
$phpmailer->ClearAllRecipients();
}