BREAKING E-MAIL LISTS INTO GROUPS OF "N" ADDRESSES EACH - Apr 4th, 2013
|
To limit abuse on their email server, some ISPs limit the number of recipients that can be included in a single email, or the amount of emails that can be sent at one time.
I encountered this problem when using an email list generated from a multi-record section of publicity email contacts.
Here's the way I broke the email list generated from the email contact records into groups of acceptable numbers.
For this example, you'll need to create a multi-record editor called "publicity" with 2 text fields, "title" and "email"
I also added a max_emails text field in a single record editor called "Common Information" to determine the number of emails allowed in each group.
If statements are used to set the criteria for different email lists. To refine which emails appear in each of your lists, you can use as many criteria as you want to.
In this example there's only one email list displayed on the page, but there are 2 counters used. "counta" to display the total number of records containing email addresses in the list and "countb" to limit the number of emails in each group. Because I wanted the total number to appear above the email list it was associated with, a separate foreach loop, with identical criteria was created to increment counta . You can name your counter variables anything you want, but make sure that each counter variable is unique.
Then, if you're using divs to generate the groups, use the following code in the body of your list viewer
Where you want the Information header to appear:
NOTE: To help to conform to ISP reciepient limits, email addresses are separated into groups of no more than <?php echo $common_informationRecord['max_emails'] ?> addresses each. System administrators can change this number in the "Common Information" editor.
Where you want the list heading to appear:
<div align="left"> <?php $counta = 0; ?> <?php foreach ($publicityRecords as $record ): ?> <?php if ($record['email']): ?> <?php $counta++; ?> <?php endif ?> <?php endforeach; ?> <span class="your_class">There are currently <?php echo $counta ?> addresses in this list .</span> </div>
And where you want the email list to appear:
<div align="left"> <?php $countb = 0; ?> <?php foreach ($publicityRecords as $record): ?> <?php if ($record['email']): ?> <?php $countb++; ?> <?php echo $record['email'] ?>; <?php endif ?> <?PHP $maxemails= $common_informationRecord['max_emails']; ?> <?php if ($countb >= $maxemails): ?> <?php $countb = 0; ?> </div> <div align="left"> <br /> <hr > <br /> <?php endif ?> <?php endforeach ?> </div>
If you're using tables, in place of the code:
<?php if ($countb >= $maxemails): ?> <?php $countb = 0; ?> </div> <div align="left"> <br /> <hr > <br /> <?php endif ?> <?php endforeach ?> </div>
substitute
<?php if ($countb >= $maxemails): ?> <?php $countb = 0; ?> </td></tr><tr><td> <br /> <hr /> <br /> <?php endif ?> <?php endforeach ?> </td> </tr> </table>
|
The materials on this web site have been created for use with CMS Builder content management software. CMS Builder software is published and licensed for use by InteractiveTools.com. Please contact
Interactive Tools for information on the downloading of the software or the purchasing of licenses.