getting 500 internet server error while using php email

Goinfory

Registered
Jun 4, 2015
1
0
1
London
cPanel Access Level
Website Owner
Hi, i want to send email to my 600 clients through php email. but the loop works till 20 contacts, after that it show 500 internal server error. I am using - Removed - server. Here is the script:

Code:
<?php
for($x=1;$x<=600;$x++)
{
$con = mysqli_connect("host","database","password");
if (!$con){die('Could not connect: ' . mysqli_error($con));}
mysqli_select_db($con,"database");
$sql="SELECT email FROM emails Where id = ".$x;
$result = mysqli_query($con,$sql);
$row = mysqli_fetch_array($result);
$to = $row['email'];
if ($to == "NULL")
{

}
else
{
  echo $row['email'];
mysqli_close($con);
// mail($to,"subject","message");
sleep(2);
}
}
?>
 
Last edited by a moderator:

cPanelMichael

Administrator
Staff member
Apr 11, 2011
47,880
2,267
463
Hello,

What error message do you see in /usr/local/apache/logs/error_log when the "500" message appears in your browser?

Thank you.