Hi, do I need to LIMIT my blast script to fire out an emailer or can I just take it out. We have around 500 email address in our database. Having to reload the script is going to become painful - is there anything I can do?
My hosting provider does not support cronjobs.
<?php
include_once "connection.php";
$sql = mysql_query("SELECT * FROM addresses WHERE received='1' LIMIT 20");
$numRows = mysql_num_rows($sql);
// Added for "End Campaign Check" at the bottom of this file(not shown on the video)
$mail_body = '';
while($row = mysql_fetch_array($sql)){
$id = $row["id"];
$email = $row["email"];
$mail_body = 'Hello this is a test!';
$subject = "TEST EMAILER";
$headers = "From:info@mifsuds.com\r\n";
$headers .= "Content-type: text/html\r\n";
$to = "$email";
$mail_result = mail($to, $subject, $mail_body, $headers);
if ($mail_result) {
mysql_query("UPDATE addresses SET received='0' WHERE email='$email' LIMIT 1");
} else {
// this else statement can be used to write into an error log if the mail function fails
// It can also be removed if you do not need error logging
}
}
?>
<?php
// This section is script I discussed adding to this file on video
// This section is for sending the site owner a message informing them that
// all people in the database have been sent the newsletter for the current campaign
if (!$numRows == 0) { // $numRows is set on line 4 using the existing query
$subj = "Newsletter Campaign Has Ended";
$body = "The current newsletter campaign has ended. All have been sent the newsletter.";
$hdr = "From:info@test.com\r\n";
$hdr .= "Content-type: text/html\r\n";
mail("example@gmail.com", $subj, $body, $hdr);
}
// End Check Section
?>