aaargh, I'm frustrated with this stuff...I really need someone to help me! (again)
I am not too familiar with configuring Sendmail (and I don't still get what the hell M4 is all about)...but I know what I am doing to an extent with Sendmail. I just need some help with possibly a configuration directive (a time out maybe)...here is my scenario:
I have a list of about 20,000 subscribed emails (I am running FreeBSD). I'm using a PHP script that I've written to query a mySQL database for email address's and then send an email out to each one. But my problem is that I am only able to send 1,000 or so at a time. I believe this is a problem from within Sendmail because I have already setup my Server & PHP to allow no time outs whatsoever! --I've been trying to figure this out for a day or 2 now.
I have done some error handling / debugging and it looks like the connection status is Normal & OK between my script, the server, the client and the database...SO, that means it must be Sendmail timing out. I have tried setting up Multiple Queues, and that did not help any. The reason why I think it is timing out and not hitting a message send limit is because I have had it give me the same error/problem with only 200 - 500 messages being sent from within the same length of time as it took to send 1,000+ (I have tested this!). SENDMAIL MUST BE TIMING OUT!
Can anyone help me??
--------
(even tho I know my PHP script works fine)
HERE IS MY CODE anyways:
--------
<?php
function sendStart()
{// Start & build email_id evaluation integers, variable & array definitions, and the SQL conditional expressions for each query!
$a = 16566;
$b = 500;
$x = 0;
$i = 0;
$evals2 = array(0,1,2,3,4,5,6,7,8,9);
$temp = array();
$temp2 = array();
$evals = array();
$dba = array("hostname","user","password","DBname"
$file = "email_body.txt";
$logfile = "email_send.log";
$logfile2 = "email_send_skipped.log";
$fd = fopen($file,"r"
$body = fread($fd,filesize($file));
fclose($fd);
$fp = fopen($logfile,"w"
$fp2 = fopen($logfile2,"w"
foreach($evals2 as $eval)
{if($eval == 0 && $i == 0)
{$eval = $a + $b;
$temp[$i] = $eval;
$y = $i;
}
if($i > 0 && $eval <= count($evals2) - 1)
{$eval = $temp[$y] + $b;
$temp[$i] = $eval;
$y = $i;
}
$evals2[$i] = $eval;
$i++;
}
foreach($evals2 as $eval)
{$eval++;
$temp2[$x] = $eval;
$x++;
}
for($i=0;$i<count($evals2);$i++)
{if(isset($e))
{if($i == count($evals2) - 1)
break;
$e = $i + 1;
$evals[$i] = "> $evals2[$i] AND email_id < $temp2[$e]";
}
else
{$e = $i + 1;
$evals[$i] = ">$evals2[$i] AND email_id < $temp2[$e]";
}
}
// Start database queries & email sending for each matching record/row found!
foreach($evals as $eval)
{$link = mysql_connect($dba[0],$dba[1],$dba[2]);
if(!$link)
die("Couldn't connect to mysqld!"
mysql_select_db($dba[3],$link) or die("Couldn't open $dba[3]: ".mysql_error());
if(isset($delay))
sleep(20);
$query1 = "SELECT email,email_id FROM email_list WHERE email_id $eval";
$result = mysql_query($query1,$link);
if(!$result)
{print mysql_error();
print mysql_affected_rows();
}
while($rows = mysql_fetch_assoc($result))
{if(file_exists($logfile))
$fp = fopen($logfile,"a"
$send = mail($rows,"EMAIL SUBJECT!",$body,"From: myemail@mydomain.com (A1SuperCruises.com)\nContent-Type: text/plain\n"
$last_id = $rows[email_id];
fputs($fp,"$rows[email] - $rows[email_id] - $x\n"
$x++;
}
flush();
$delay = 1;
mysql_free_result($result);
}
fclose($fp);
fclose($fp2);
}
function shutdown_info()
{$error_log = "email_send_errors.log";
$fp = fopen($error_log,"w"
if(connection_aborted())
fputs($fp,"The client has disconnected.<br>\n"
if(connection_timeout())
fputs($fp,"The connection has timed out.<br>\n"
if(mysql_error())
fputs($fp,"An error has occurred in mySQL: ".mysql_error()."<br>\n"
fputs($fp,connection_status());
}
// Do the job right!
ignore_user_abort(true);
set_time_limit(0);
register_shutdown_function("shutdown_info"
sendStart();
?> [b]- PAINKILLER [/b]
I am not too familiar with configuring Sendmail (and I don't still get what the hell M4 is all about)...but I know what I am doing to an extent with Sendmail. I just need some help with possibly a configuration directive (a time out maybe)...here is my scenario:
I have a list of about 20,000 subscribed emails (I am running FreeBSD). I'm using a PHP script that I've written to query a mySQL database for email address's and then send an email out to each one. But my problem is that I am only able to send 1,000 or so at a time. I believe this is a problem from within Sendmail because I have already setup my Server & PHP to allow no time outs whatsoever! --I've been trying to figure this out for a day or 2 now.
I have done some error handling / debugging and it looks like the connection status is Normal & OK between my script, the server, the client and the database...SO, that means it must be Sendmail timing out. I have tried setting up Multiple Queues, and that did not help any. The reason why I think it is timing out and not hitting a message send limit is because I have had it give me the same error/problem with only 200 - 500 messages being sent from within the same length of time as it took to send 1,000+ (I have tested this!). SENDMAIL MUST BE TIMING OUT!
Can anyone help me??
--------
(even tho I know my PHP script works fine)
HERE IS MY CODE anyways:
--------
<?php
function sendStart()
{// Start & build email_id evaluation integers, variable & array definitions, and the SQL conditional expressions for each query!
$a = 16566;
$b = 500;
$x = 0;
$i = 0;
$evals2 = array(0,1,2,3,4,5,6,7,8,9);
$temp = array();
$temp2 = array();
$evals = array();
$dba = array("hostname","user","password","DBname"
$file = "email_body.txt";
$logfile = "email_send.log";
$logfile2 = "email_send_skipped.log";
$fd = fopen($file,"r"
$body = fread($fd,filesize($file));
fclose($fd);
$fp = fopen($logfile,"w"
$fp2 = fopen($logfile2,"w"
foreach($evals2 as $eval)
{if($eval == 0 && $i == 0)
{$eval = $a + $b;
$temp[$i] = $eval;
$y = $i;
}
if($i > 0 && $eval <= count($evals2) - 1)
{$eval = $temp[$y] + $b;
$temp[$i] = $eval;
$y = $i;
}
$evals2[$i] = $eval;
$i++;
}
foreach($evals2 as $eval)
{$eval++;
$temp2[$x] = $eval;
$x++;
}
for($i=0;$i<count($evals2);$i++)
{if(isset($e))
{if($i == count($evals2) - 1)
break;
$e = $i + 1;
$evals[$i] = "> $evals2[$i] AND email_id < $temp2[$e]";
}
else
{$e = $i + 1;
$evals[$i] = ">$evals2[$i] AND email_id < $temp2[$e]";
}
}
// Start database queries & email sending for each matching record/row found!
foreach($evals as $eval)
{$link = mysql_connect($dba[0],$dba[1],$dba[2]);
if(!$link)
die("Couldn't connect to mysqld!"
mysql_select_db($dba[3],$link) or die("Couldn't open $dba[3]: ".mysql_error());
if(isset($delay))
sleep(20);
$query1 = "SELECT email,email_id FROM email_list WHERE email_id $eval";
$result = mysql_query($query1,$link);
if(!$result)
{print mysql_error();
print mysql_affected_rows();
}
while($rows = mysql_fetch_assoc($result))
{if(file_exists($logfile))
$fp = fopen($logfile,"a"
$send = mail($rows,"EMAIL SUBJECT!",$body,"From: myemail@mydomain.com (A1SuperCruises.com)\nContent-Type: text/plain\n"
$last_id = $rows[email_id];
fputs($fp,"$rows[email] - $rows[email_id] - $x\n"
$x++;
}
flush();
$delay = 1;
mysql_free_result($result);
}
fclose($fp);
fclose($fp2);
}
function shutdown_info()
{$error_log = "email_send_errors.log";
$fp = fopen($error_log,"w"
if(connection_aborted())
fputs($fp,"The client has disconnected.<br>\n"
if(connection_timeout())
fputs($fp,"The connection has timed out.<br>\n"
if(mysql_error())
fputs($fp,"An error has occurred in mySQL: ".mysql_error()."<br>\n"
fputs($fp,connection_status());
}
// Do the job right!
ignore_user_abort(true);
set_time_limit(0);
register_shutdown_function("shutdown_info"
sendStart();
?> [b]- PAINKILLER [/b]