Trying to send emails with multiple attachments using PHPMailer
require is fine $mail = new PHPMailer(); is fine script stops working when I start adding in the parameters for the mails.
PHP function :
function kamp_bulk_mail(){
require $_SERVER['DOCUMENT_ROOT'].'/assets/PHPMailer-master/PHPMailerAutoload.php';
require $_SERVER['DOCUMENT_ROOT'].'/assets/PHPMailer-master/class.phpmailer.php';
$content = mysqli_fetch_array(sql('select','select * from kampen_mailtemplate where kamp = '.$_POST['id']));
$spelers = sql('select','select * from kampen_spelers where kamp = '.$_POST['id']);
while($spelers_ = mysqli_fetch_array($spelers)){
echo "1";
$mail = new PHPMailer(true);
try {
echo "2";
$mail->From("test@sender.be");
echo "3";
$mail->FromName("Admin");
$mail->addAddress($spelers_['email_voogd']);
echo "4";
foreach(glob("kampen/configuratie/bijlagen/".$_POST['id']."_*") as $filename){
$mail->addAttachment($filename);
}
echo "5";
$mail->Subject = $content['titel'];
$mail->Body = $content['content'];
}
catch(phpmailerException $e){
echo $e->errorMesage();
}
if(!$mail->send()) {
echo 'Message could not be sent.';
echo 'Mailer Error: ' . $mail->ErrorInfo;
} else {
echo 'Message has been sent';
}
}
}
This echoes 12
EDIT : adjusted code to show where the problem begins