Learn the essential features and functions of the popular JavaScript framework for building mobile, desktop and web applications.
<?php
$list = file('list.txt');
foreach ($list as $line) {
$info = explode(",", $line);
$email = $info[0];
$firstname = $info[1];
$lastnameraw = $info[2];
$lastname = str_replace("\r\n","",$lastnameraw);
$fullname = "$firstname $lastname";
$fromemail = "";
$fromname = "";
$replyto = "";
$header = "From: $fromname <$fromemail>\r\nReply-To: $replyto\r\n";
$header .= "MIME-Version: 1.0\r\n";
$header .= "Content-Type: text/html\r\n";
$header .= "Content-Transfer-Encoding: 8bit\r\n\r\n";
$header .= "$message\r\n";
$subject = "";
$message = "";
mail($email, $subject, "", $header);
}
?>
Do more with
How can i make it remember what emails were sent to not resend them and then reconnect and continue?You can use a data base. Make it a "log" table. As each email is sent, add it to the log. Whenever the script has to be restarted, SELECT the already sent emails from the log, and skip sending the email if the log contains an indicator that the message has already been sent.
<?php
error_reporting(E_ALL);
$list = "list.txt";
$hosts = "hosts.txt";
$listcount = count(file($list));
$hostscount = count(file($hosts));
$splitnum = (int)($listcount / $hostscount);
$handle = fopen("list.txt", "r");
$currentfile = 1;
$output = FALSE;
if ($list)
{
while (!feof($handle))
{
$buffer = fgets($handle, 4096);
if (!$output)
{
$output = fopen("list.txt" . ($currentfile++), "w");
$lines = 0;
}
fwrite($output, $buffer);
if (strrchr($buffer,"\n"))
{
$complete = TRUE;
++$lines;
if ($lines == $splitnum)
{
fclose($output);
$output = FALSE;
}
}
else
{
$complete = FALSE;
}
}
fclose($handle);
if ($output)
{
if (!$complete)
{
fwrite($output,"\n");
}
fclose($output);
}
}
Premium Content
You need an Expert Office subscription to comment.Start Free Trial