how to throttle php mailing list ?

Hi there,

I have a mailing list script that i am using to send out an email to everyone on my database. The problem i am having is that my host will only let me send the email to 4 addresses at once and there is a limit of 500 per hour.

How can i make it so the script just sends out 4 emails at a time an no more than 500 an hour?

this is the code i am using:

[php]

<?php require('connect.php'); // Grab our config settings require_once($_SERVER['DOCUMENT_ROOT'].'/config.php'); // Grab the FreakMailer class require_once($_SERVER['DOCUMENT_ROOT'].'/include/MailClass.inc'); /* Note: set_time_limit() does not work with safe_mode enabled */ $result_message = ''; if (isset($_POST['submit'])) { $errors = array(); if (empty($_POST['email_addresses'])) { $errors['emails'] = 'No emails selected.'; } // here you can/should loop through and verify email addresses to avoid spamming; put a restriction to # of emails allowed to be sent, etc. // santizing/controlling your email functions is greatly overlooked and can cause your site to be dropped by your hosting provider if your site is being used to send gobs of spam if (empty($errors)) { $result_message = 'There was a problem sending this mail!'; // instantiate the class $mailer = new FreakMailer(); // Build foreach ($_POST['email_addresses'] as $email_address) { $mailer->AddBCC($email_address); } // Set the subject $mailer->Subject = 'New Products from The Organic Grow Shop'; $mailer->isHTML(true); if ($mailer->Send()) { $result_message = 'Mail sent!'; } $mailer->ClearAddresses(); $mailer->ClearAttachments(); } } $sql = "SELECT * FROM mailinglist"; if ($result = mysql_query($sql)) { if (mysql_num_rows($result) > 0) { echo (!empty($result_message) ? $result_message .'

' : ''); echo "

Mailing List

Send to

"; while ($getrow = mysql_fetch_assoc($result)) { echo "". $getrow['email'] ."
"; } echo ""; } else { echo 'Add some email addresses.'; } } else { trigger_error(mysql_error()); } ?>[/php]

Anyone?

Really need some help with this! Is doing my head in!

In the config (config/config.php) file of phpmailr make the following changes. This limts the sending emails to 450 emails per hour.
[php]

define the amount of emails you want to send per period. If 0, batch processing

is disabled and messages are sent out as fast as possible

define(“MAILQUEUE_BATCH_SIZE”,0);

define the length of one batch processing period, in seconds (3600 is an hour)

define(“MAILQUEUE_BATCH_PERIOD”,3600);

to avoid overloading the server that sends your email, you can add a little delay

between messages that will spread the load of sending

you will need to find a good value for your own server

value is in seconds (or you can play with the autothrottle below)

define(‘MAILQUEUE_THROTTLE’,8);

[/php]

Hi there,

I tried changing the config.php file but it still hasn’t worked.

Any ideas what might be wrong?

First, (/* Note: set_time_limit() does not work with safe_mode enabled */) might be a clue…

Also try setting (define(“MAILQUEUE_BATCH_SIZE”,0):wink: to 100. This should send 100 per hour, well under your limit and if your sending more that 2400 emails in a day, you are spamming!

Ok, so i got my host to turn of safe_mode in the php.ini file.

I have tried changing the batch size etc but it still does not work!

I don’t know what i am doing wrong!

if you’re altering the config file and it is not reflecting the change, it is most likely not reading the config file. chmod it, to make sure it has the proper permissions. While your at it make sure all your files are properly chmod’d.

Hi Aztech,

Here is the config file :

[php]<?php

define the amount of emails you want to send per period. If 0, batch processing

is disabled and messages are sent out as fast as possible

define(“MAILQUEUE_BATCH_SIZE”,100);

define the length of one batch processing period, in seconds (3600 is an hour)

define(“MAILQUEUE_BATCH_PERIOD”,3600);

to avoid overloading the server that sends your email, you can add a little delay

between messages that will spread the load of sending

you will need to find a good value for your own server

value is in seconds (or you can play with the autothrottle below)

define(‘MAILQUEUE_THROTTLE’,8);

// Email Settings
$site[‘from_name’] = ‘test’; // from email name
$site[‘from_email’] = ‘[email protected]’; // from email address
$mailer[‘Body’] = $htmlBody;

// Just in case we need to relay to a different server,
// provide an option to use external mail server.
$site[‘smtp_mode’] = ‘disabled’; // enabled or disabled
$site[‘smtp_host’] = null;
$site[‘smtp_port’] = null;
$site[‘smtp_username’] = null;
?>[/php]

I’m sure that my script is reading the config file because i just changed the ‘from email name’ and it had changed on the email i received.

What else could it be?

Please Help Me :o

I still can’t get this to work. any ideas what else it could be?

Hello people,

Can anyone out there help me figure out how to get my php mailing list to send an email to everyone in my database?

I am using php mailer and have tried using the ‘MAILQUEUE_THROTTLE’ function. but it does not seem to work !

Is there any other way around this, i just can’t understand why it won’t work!!

when i try to send emails from my database manually i can only send 4 at a time…

have you tried replacing the config file as suggested by sajan, your first area states

[php]# define the amount of emails you want to send per period. If 0, batch processing

is disabled and messages are sent out as fast as possible

define(“MAILQUEUE_BATCH_SIZE”,100);[/php]

he suggested using

[php]# define the amount of emails you want to send per period. If 0, batch processing

is disabled and messages are sent out as fast as possible

define(“MAILQUEUE_BATCH_SIZE”,0);[/php]

try this…

PS… you should let each person know if their help works or not and what happens, nobody is able to know what you have done already if you just post HELP ME in a continuous manner. This does take a little time to look over your codes and try and fix them, nobody can guess and be correct.

Sponsor our Newsletter | Privacy Policy | Terms of Service