setLanguage($lang, 'vendor/phpmailer/phpmailer/language/phpmailer.lang-'.$lang.'.php'); $mail->CharSet = 'utf-8'; //$mail->SMTPDebug = 5; // Enable verbose debug output //$mail->isSMTP(); // Set mailer to use SMTP $mail->Host = $smtpHost; // Specify main and backup SMTP servers //$mail->SMTPAuth = true; // Enable SMTP authentication //$mail->Username = $sender; // SMTP username //$mail->Password = $credential_pw; // SMTP password //$mail->SMTPSecure = $algo_sec; // Enable TLS encryption, `ssl` also accepted $mail->Port = $port; // TCP port to connect to $mail->isHTML(false); // Set email format to HTML $mail->setFrom($sender, $senderName); $mail->Subject = $subject; //$db->debug = true; $file = fopen($filename, "r"); while(!feof($file)){ $line = fgets($file); $sanitized_mail = filter_var($line, FILTER_SANITIZE_EMAIL); if($sanitized_mail !== "") { $mail->addAddress($sanitized_mail); $token = getToken(); $link = generateLink($mlrollmember_url, $token, $ml, $sanitized_mail); $mail->Body = $def_body.$link; $db->$db_table()->insert(array( "token" => $token, "ml" => $ml, "email" => $sanitized_mail )); if(!$mail->send()) { echo 'Message could not be sent.'."\n"; echo 'Mailer Error: ' . $mail->ErrorInfo."\n"; } else { echo 'Message has been sent'."\n"; } } } fclose($file);