$recFile doesn\'t exist or cannot be read"); } require($phpmailerLoc); require('sentlogger.php'); $mail = new PHPMailer(); // something I had to do on our servers to solve the language problem if (!$mail->setLanguage('en', '/usr/www/users/xxxxx/mailgun/phpmailer/language/')) { print "
Language error"; exit(); } //$mail->IsSMTP(); // disabled, sendmail feels better atm //$mail->SMTPAuth = 'true'; $mail->Host = $smtpHost; $mail->Username = $smtpUser; $mail->Password = $smtpPass; $mail->SMTPKeepAlive = 'true'; $mail->Priority = '4'; $mail->Subject = $subject; $mail->IsHTML(true); $mail->From = 'whatever@yourdomain.com'; $mail->FromName = $fromName; $mail->AddReplyTo($from); // read the mail contents from $contentFile and have it available... $foo = $mail->getFile($contentFile); // should we attach something? if($attach) { if (is_readable($attach) == false) { die("$attach doesn\'t exist or cannot be read"); } $mail->AddAttachment($attach, "", "base64", "application/octet-stream"); } // set html and text-only mail bodies $mail->Body = $foo; $mail->AltBody="This message is intended for html reading, which you currently do not have enabled\r\n"; // show and set execution time limits print "
Initial Max-exec-time: " . ini_get('max_execution_time'); set_time_limit(0); print "
New Max-exec-time: " . ini_get('max_execution_time'); flush(); if($testmode) { print "
Testmode Engaged"; print "
Sending only to $tester"; $mail->Subject = "TestMode Mail:" . $subject; $mail->AddAddress($tester); if(!$mail->Send()) { print " OOPS! - " . $mail->ErrorInfo; } else { print " Sent, check your inbox"; } print "

Testing completed :->"; exit(); } // main loop - read address per line, and fire off email $mailcount = 1; // $centuries = 0; // todo: cool feature that prints a notice every 100 lines. defy boredom. $errorcount = 0; $handle = fopen($recFile, "r"); while (($data = fgetcsv($handle, 1000, ",")) !== FALSE) { print "
Dispatching #$mailcount > "; print $data[0]; flush(); if(sentlogger_check($data[0])) { print " - Skipping, already in sentmail_gun table"; $mailcount++; continue; } $mail->AddAddress($data[0]); if(!$mail->Send()) { print " !! OOPS !! - " . $mail->ErrorInfo; $errorcount++; continue; } fwrite($f, $data[0]); // if sent, write this email add into the sent file print " ~ Sent"; flush(); sentlogger_ping($data[0]); $mail->ClearAddresses(); //$mail->ClearAttachments(); sleep($maildelay); //usleep(800000); $mailcount++; } fclose($f); fclose($handle); print "

Completed: Done with $mailcount emails and $errorcount errors"; ?>