Zen Cart Logo
Forums / Managing Customers and Orders / throttling newsletter sending

throttling newsletter sending

Views: 3,068

Results 1 to 17 of 17
24 Nov 2011, 12:39 AM
#1
willie_bee avatar

willie_bee

Zen Follower

Join Date:
Mar 2011
Posts:
386
Plugin Contributions:
0

throttling newsletter sending

Is there not a better solution in sending out emails. We have over 5K subscribers and I do not think it all went through.

I would think there would be a "throttle" configuration to send out 100 emails at a time.

I know in oscommerce there is a mod that we used to set to send 100 emails at a time but we would have to go back and hit resend to send another 100 emails at a time and the email system would keep a total count track

here is the mod

24 Nov 2011, 5:34 PM
#2
schoolboy avatar

schoolboy

Totally Zenned

Join Date:
Jun 2005
Location:
Cumbria, UK
Posts:
10,327
Plugin Contributions:
0

Re: throttling newsletter sending

willie bee:

Is there not a better solution in sending out emails. We have over 5K subscribers and I do not think it all went through.

I would think there would be a "throttle" configuration to send out 100 emails at a time.

I know in oscommerce there is a mod that we used to set to send 100 emails at a time but we would have to go back and hit resend to send another 100 emails at a time and the email system would keep a total count track

here is the mod

ZC is opensource, and as such you are at liberty to modify / add any component you wish. If you would like a throttle config, then there is absolutely no law in the universe that stops you from coding one.

Why the expectation that it "should be there"?

It isn't... and if you want it, then write it.

24 Nov 2011, 7:02 PM
#3
Kim avatar

Kim

Obaa-san

Join Date:
Jun 2003
Location:
West Coast, North America
Posts:
26,615
Plugin Contributions:
0

Re: throttling newsletter sending

With that many subscribers - I would look at a real contact manager instead of expecting your shopping cart to do everything.

24 Nov 2011, 8:23 PM
#4
willie_bee avatar

willie_bee

Zen Follower

Join Date:
Mar 2011
Posts:
386
Plugin Contributions:
0

Re: throttling newsletter sending

schoolboy:

ZC is opensource, and as such you are at liberty to modify / add any component you wish. If you would like a throttle config, then there is absolutely no law in the universe that stops you from coding one.

Why the expectation that it "should be there"?

It isn't... and if you want it, then write it.

God you're so smart.
No I wasn't expecting or expect anyone to do anything for me.

It was a thought as in "wouldn't one expect this for a shopping cart so popular have this function?"

Heres a suggestion. Dont be so bold over the internet. All it shows that your weak in person. Simply put you would probably be a lot nicer with your comment in person. So "keyboard warrior" your response in the same fashion.

24 Nov 2011, 8:38 PM
#5
Kim avatar

Kim

Obaa-san

Join Date:
Jun 2003
Location:
West Coast, North America
Posts:
26,615
Plugin Contributions:
0

Re: throttling newsletter sending

Moderator's note - don't turn this into a flame war. Opinions are one thing and personal insults and attacks are another.

24 Nov 2011, 8:40 PM
#6
willie_bee avatar

willie_bee

Zen Follower

Join Date:
Mar 2011
Posts:
386
Plugin Contributions:
0

Re: throttling newsletter sending

Kim:

Moderator's note - don't turn this into a flame war. Opinions are one thing and personal insults and attacks are another.

Your right. Suggest to the replier to word his sarcastic comments differently.

24 Nov 2011, 9:44 PM
#7
drbyte avatar

drbyte

Sensei

Join Date:
Jan 2004
Posts:
63,513
Plugin Contributions:
176

Re: throttling newsletter sending

willie bee:

Your right. Suggest to the replier to word his sarcastic comments differently.
Moderator note: Yes. Good advice. For both of you.

26 Nov 2011, 12:59 AM
#8
skipwater avatar

skipwater

Totally Zenned

Join Date:
Jun 2008
Location:
Washington, DC
Posts:
775
Plugin Contributions:
1

Re: throttling newsletter sending

willie bee:

Is there not a better solution in sending out emails. We have over 5K subscribers and I do not think it all went through.

I would think there would be a "throttle" configuration to send out 100 emails at a time.
I have been using this hack I did a long time ago. It is not pretty but works.

Use at your own risk.

admin/includes/modules/newsletters/newsletter.php

Around line 89 to look like this:

    function send($newsletter_id) {
      global $db;
      $audience_select = get_audience_sql_query($this->query_name, 'newsletters');
      $audience = $db->Execute($audience_select['query_string']);
      $records = $audience->RecordCount();
      if ($records==0) return 0;
    $i=0;
    // There is a 600 second time limit set for email in
    // admin/newsletters.php line 359 might have to increase 
    // if more then 1500 newsletters
    // add sleep after ## emails
    $slp=0;

      while (!$audience->EOF) {
    $i++;
    $slp++;
      $html_msg['EMAIL_FIRST_NAME'] = $audience->fields['customers_firstname'];
      $html_msg['EMAIL_LAST_NAME']  = $audience->fields['customers_lastname'];
      $html_msg['EMAIL_MESSAGE_HTML'] = $this->content_html;
      zen_mail($audience->fields['customers_firstname'] . ' ' . $audience->fields['customers_lastname'], $audience->fields['customers_email_address'], $this->title, $this->content, STORE_NAME, EMAIL_FROM, $html_msg, 'newsletters');
      echo zen_image(DIR_WS_ICONS . 'tick.gif', $audience->fields['customers_email_address']);

      //force output to the screen to show status indicator each time a message is sent...
      if (function_exists('ob_flush')) @ob_flush();
      @flush();
	
		if ($slp >= 50) { // sleep after 50 emails
	  		sleep(15); // sleep 15 seconds
	  		$slp=0;
		}


      $audience->MoveNext();
      }

Skip

27 Nov 2011, 4:44 AM
#9
willie_bee avatar

willie_bee

Zen Follower

Join Date:
Mar 2011
Posts:
386
Plugin Contributions:
0

Re: throttling newsletter sending

Thanks again skip. One question and im asking ahead of time when i shouldnt. but after i put this code in is there a way to run a test to see if it actually works because some of us stink
at modifying code.
thanks so much and i hope yall had a good thanksgiving.

28 Nov 2011, 6:39 PM
#10
skipwater avatar

skipwater

Totally Zenned

Join Date:
Jun 2008
Location:
Washington, DC
Posts:
775
Plugin Contributions:
1

Re: throttling newsletter sending

willie bee:

Thanks again skip. One question and im asking ahead of time when i shouldnt. but after i put this code in is there a way to run a test to see if it actually works because some of us stink
at modifying code.
thanks so much and i hope yall had a good thanksgiving.

Yes with more work.

I use this All Administrators hack to communicate information between all the admins of a ZC site. But it is used as a newsletter and email testing bed also.

  1. You will need 4 to 8 email address that you have access to.
  2. Each email you have you will create a ZC admin account for each. (Tools->Admin Settings)
  3. Using phpmyadmin locate query_builder table now find the record with mail,newsletters : Administrator in it and copy the whole record to create a new record with the information.
  4. Open the new record and edit the field query_name and query_string:
    From this query_name
Administrator

To

All Administrators

From this query_string

select 'ADMIN' as customers_firstname, admin_name as customers_lastname, admin_email as customers_email_address from TABLE_ADMIN where admin_id = $SESSION:admin_id

To this

select 'ADMIN' as customers_firstname, admin_name as customers_lastname, admin_email as customers_email_address from TABLE_ADMIN
  1. Now when you go to send newsletters in the dropdown you will see a new listing All Administrators. (These are the emails of all the admin accounts.)
  2. Based on how many email address you have in the ZC admin accounts. Is how many emails per sleeps we set in the hack.
    Example: You have 6 admin account email address. You want to sleep after 2 emails.
    Change from this
if ($slp >= 50) { // sleep after 50 emails

To this

if ($slp >= 2) { // sleep after 50 emails
  1. After testing you will set $slp back to 50 or if you want 100 etc.

As always backup your work.

Skip

5 Dec 2011, 9:28 PM
#11
willie_bee avatar

willie_bee

Zen Follower

Join Date:
Mar 2011
Posts:
386
Plugin Contributions:
0

Re: throttling newsletter sending

skipwater:

Yes with more work.

I use this All Administrators hack to communicate information between all the admins of a ZC site. But it is used as a newsletter and email testing bed also.

  1. You will need 4 to 8 email address that you have access to.
  2. Each email you have you will create a ZC admin account for each. (Tools->Admin Settings)
  3. Using phpmyadmin locate query_builder table now find the record with mail,newsletters : Administrator in it and copy the whole record to create a new record with the information.
  4. Open the new record and edit the field query_name and query_string:
    From this query_name

Administrator

> To
> ```
All Administrators

From this query_string

select 'ADMIN' as customers_firstname, admin_name as customers_lastname, admin_email as customers_email_address from TABLE_ADMIN where admin_id = $SESSION:admin_id

> To this
> ```
select 'ADMIN' as customers_firstname, admin_name as customers_lastname, admin_email as customers_email_address from TABLE_ADMIN
  1. Now when you go to send newsletters in the dropdown you will see a new listing All Administrators. (These are the emails of all the admin accounts.)
  2. Based on how many email address you have in the ZC admin accounts. Is how many emails per sleeps we set in the hack.
    Example: You have 6 admin account email address. You want to sleep after 2 emails.
    Change from this

if ($slp >= 50) { // sleep after 50 emails

> To this
> ```
if ($slp >= 2) { // sleep after 50 emails
  1. After testing you will set $slp back to 50 or if you want 100 etc.

As always backup your work.

Skip

Looks like that worked but I do not think all 5K emails got the newsletter.

Tell me if I am wrong.

On the next newsletter should I create a new fake account and send out the newsletter again and if that LAST account got the newsletter then it all went through?

I'm thinking the newsletter goes out in order of the accounts, from oldest to newest. TIA.

5 Dec 2011, 11:01 PM
#12
skipwater avatar

skipwater

Totally Zenned

Join Date:
Jun 2008
Location:
Washington, DC
Posts:
775
Plugin Contributions:
1

Re: throttling newsletter sending

You missed the math:
// There is a 600 second time limit set for email in
// admin/newsletters.php line 359 might have to increase
// if more then 1500 newsletters

5000 / 1500 = 3.3 so you need 3x more time +

You will need to up the time limit in the file admin/newsletters.php about line 359 to 4 x 600 = 2400

Skip

5 Dec 2011, 11:37 PM
#13
willie_bee avatar

willie_bee

Zen Follower

Join Date:
Mar 2011
Posts:
386
Plugin Contributions:
0

Re: throttling newsletter sending

Thanks, but does what I say about how ZC sends out newletters hold true? By oldest email up to newest?

I guess this way others reading this thread can do the same and create a mock account with their email and see if they get it in the end.

5 Dec 2011, 11:45 PM
#14
drbyte avatar

drbyte

Sensei

Join Date:
Jan 2004
Posts:
63,513
Plugin Contributions:
176

Re: throttling newsletter sending

By default Zen Cart doesn't implement ANY sort order for newsletter subscribers, so thus it relies completely on the order determined most appropriate by the MySQL database.

If you want to change the order, you'll need to change the SQL statements in the various queries in the query_builder table of your database. You'll need to use your own database tools to do that, such as phpMyAdmin. BE CAREFUL when touching raw database content. MAKE BACKUPS first.
Naturally, I recommend that if you've not used such tools before that you should NOT start using them now merely for this. USE AT OWN RISK.

10 Dec 2011, 8:26 PM
#15
willie_bee avatar

willie_bee

Zen Follower

Join Date:
Mar 2011
Posts:
386
Plugin Contributions:
0

Re: throttling newsletter sending

skipwater:

You missed the math:
// There is a 600 second time limit set for email in
// admin/newsletters.php line 359 might have to increase
// if more then 1500 newsletters

5000 / 1500 = 3.3 so you need 3x more time +

You will need to up the time limit in the file admin/newsletters.php about line 359 to 4 x 600 = 2400

Skip

I know man, another dumb question but sometimes my hand needs to be held so I apologize in advance, haha.

I did another newsletter and looks like each graphical check mark is an email. I actually, yes, actually counted them and looks like I got halfway through before the email gave up and stopped.

So do you think x 6 instead of x 3 would be sufficient or is there some other else configuration I should look into changing. FYI, these are really nothing more than txt newsletters with HTML links to twitter and fb. TIA.

10 Dec 2011, 10:17 PM
#16
skipwater avatar

skipwater

Totally Zenned

Join Date:
Jun 2008
Location:
Washington, DC
Posts:
775
Plugin Contributions:
1

Re: throttling newsletter sending

willie bee:

I know man, another dumb question but sometimes my hand needs to be held so I apologize in advance, haha.

I did another newsletter and looks like each graphical check mark is an email. I actually, yes, actually counted them and looks like I got halfway through before the email gave up and stopped.

So do you think x 6 instead of x 3 would be sufficient or is there some other else configuration I should look into changing. FYI, these are really nothing more than txt newsletters with HTML links to twitter and fb. TIA.

Yes double it and see if they all go.

Skip

11 Dec 2011, 12:03 AM
#17
willie_bee avatar

willie_bee

Zen Follower

Join Date:
Mar 2011
Posts:
386
Plugin Contributions:
0

Re: throttling newsletter sending

DrByte:

By default Zen Cart doesn't implement ANY sort order for newsletter subscribers, so thus it relies completely on the order determined most appropriate by the MySQL database.

If you want to change the order, you'll need to change the SQL statements in the various queries in the query_builder table of your database. You'll need to use your own database tools to do that, such as phpMyAdmin. BE CAREFUL when touching raw database content. MAKE BACKUPS first.
Naturally, I recommend that if you've not used such tools before that you should NOT start using them now merely for this. USE AT OWN RISK.

Thanks. I use WinSCP and Putty and phpMyadmin for various stuff to backup datafiles. Thank you.