Biyernes, Marso 1, 2013

How to control emails when server(cPanel) is limited.

Having problems sending 5000 or more emails?. That had been my problem before and now I got my solution. For example your server can only send 400 emails per hour. My solution, use your database.

Save your email details in the database. Email address, attachments, and message.

Example:

$sql = insert into tosentbox email, message values ('a@a.aaa','sample email');
mysql_query($sql);

Now we create your cron file.

$sql = select * from tosentbox limit 0,30;
$query = mysql_query($sql);

while($row = mysql_fetch_array($query))
{
mail($row['email'],'SUBJECT',$row['message']);


Meaning your only to select the first 30 data from your database. Save as cron.php.

Final step is to set it in your server.
In your cpanel look for the advance tab and click cron job icon. This settings is to read your cron file every 5 minutes.


Add this line in the command textbox:

cd '/home/mintcoll/public_html/' ; php -q 'cron.php' > /dev/null

This is the path where your cron file is located. Then click add new cron job and youre done.

Summary, every 5 minutes the server will read your cron file that selects every 30 emails in your database to send. thus, making it 360 per hour.

Hope that helps!!..

Thanks..