sınıfın birden çok örneğini oluşturarak PHPMailer boş sayfa

0 Cevap php

Ben PHPMailer lib kullanan bir kullanıcıya bir bildirim e-posta göndermek için bir işlev oluştururken duyuyorum.

 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();
}

It works fine if i just send an email or sending multiple emails inside the class. But if do

for($i=0;$i<3;$++)
{
   $notification = new $Notification();
   $notification->notify(...);
}

It retuns a blank page. No errors, messages, nothing. Before you ask i have display_errors turned on.

Ne olabilir?

Ben sadece bu gibi PHPMailer bir örneği varsa çalışıyor:

$phpmailer = new PHPMailer($exceptions = true);
(...)

       for($i=0;$i<3;$i++)
       {
            $phpmailer->AddAddress('address');
            $phpmailer->Subject = "";
            $phpmailer->Body = "sasa";

            $phpmailer->Send();
            $phpmailer->ClearAllRecipients();
       }

0 Cevap