Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

PHP Forum


You are currently viewing our PHP Forum as a guest. Please register to participate.
Login



Freelance Jobs

Reply
More Efficient Mailing
Old 06-11-2004, 01:43 PM More Efficient Mailing
milomedia's Avatar
Super Talker

Posts: 133
Location: durango, colorado
Trades: 0
Heya,

I've got a nice CMS that I set up for my clients, over the years it has evolved to be a pretty nice package. A new feature is a mailing list manager, basically I have one table that is email addresses (all collected via the site when someone signs up - no spamming here) and a second table that makes up the actual email.

So the owner of the business goes to "email" in their manager and selects a mail that they want to send (or creates the mail) then opts to see if they want to send it to the whole list or to just one address to test.

The problem starts here

I have a while loop that goes through the email table and sends the mail to each address on the list. I'm guessing that there must be a more efficent way to do this. Now when i execute that command my browser will time out before it goes through all the emails, however, the script is fully executing, as the last people on the list did indeed receive the mail.

Should I make an array of addresses and include them as BCC? How many addresses can you put as BCC? I'd like to basically make it less resource intensive and I'd like to know that it finished rather than having my browser time out and wonder if it all happened.. Thanks in advance

Cheers... -e
__________________
_______________________________
Feeling down? listen to
Please login or register to view this content. Registration is FREE
milomedia is offline
Reply With Quote
View Public Profile Visit milomedia's homepage!
 
 
Register now for full access!
Old 06-21-2004, 01:50 PM
milomedia's Avatar
Super Talker

Posts: 133
Location: durango, colorado
Trades: 0
hrmph!
__________________
_______________________________
Feeling down? listen to
Please login or register to view this content. Registration is FREE
milomedia is offline
Reply With Quote
View Public Profile Visit milomedia's homepage!
 
Old 06-21-2004, 02:00 PM
Christopher's Avatar
Iced Cap

Latest Blog Post:
Cross-domain AJAX with JSONP
Posts: 3,110
Location: Toronto, Ontario
Trades: 0
You should do a batch at a time. You do everything as you are right now, but instead of doing the 1000 all at once, you do like 50 (for example). So just make a loop that does 50, refreshes the page, does another 50 etc etc. I'm not sure how practical 50 really is, just using it as an example.
__________________

Please login or register to view this content. Registration is FREE
- Latest Articles:
Please login or register to view this content. Registration is FREE
,
Please login or register to view this content. Registration is FREE

--
Please login or register to view this content. Registration is FREE

Christopher is offline
Reply With Quote
View Public Profile
 
Old 06-21-2004, 02:55 PM
milomedia's Avatar
Super Talker

Posts: 133
Location: durango, colorado
Trades: 0
I was thinking that.... you don't by chance know how I'd do that, do you? ;-)
__________________
_______________________________
Feeling down? listen to
Please login or register to view this content. Registration is FREE
milomedia is offline
Reply With Quote
View Public Profile Visit milomedia's homepage!
 
Old 06-21-2004, 03:00 PM
Christopher's Avatar
Iced Cap

Latest Blog Post:
Cross-domain AJAX with JSONP
Posts: 3,110
Location: Toronto, Ontario
Trades: 0
You say you have a table with the email addy's that the emails go out to? Then just do the first 50, refresh the page with a query string, then use that as your query.

PHP Code:
$start $_GET['start'];
$sql "SELECT * FROM emails LIMIT $start, 50";
// ... do all the email stuff
header('Location: myscript.php?start=' $start 50); 
You get the idea
__________________

Please login or register to view this content. Registration is FREE
- Latest Articles:
Please login or register to view this content. Registration is FREE
,
Please login or register to view this content. Registration is FREE

--
Please login or register to view this content. Registration is FREE

Christopher is offline
Reply With Quote
View Public Profile
 
Old 06-24-2004, 07:03 PM
milomedia's Avatar
Super Talker

Posts: 133
Location: durango, colorado
Trades: 0
Hi,

will header() refresh the page on its own? Reason I'm asking is, If i screw up I don't want 1500 people getting an email about it, lol


I also have some conditionals leading upto the mailing, so the client selects which campaign from a pull down, I guess I just need to send those $campaignid, etc along with each refresh?

Oh, and THANKS!!!
__________________
_______________________________
Feeling down? listen to
Please login or register to view this content. Registration is FREE
milomedia is offline
Reply With Quote
View Public Profile Visit milomedia's homepage!
 
Old 06-24-2004, 07:22 PM
Christopher's Avatar
Iced Cap

Latest Blog Post:
Cross-domain AJAX with JSONP
Posts: 3,110
Location: Toronto, Ontario
Trades: 0
Well, I'd redirect with javascript instead. That way you can be sure you don't have any pesky 'headers already sent' errors etc.

I would make an auto-submitting form. That way, any specific information you have can just be thrown into a hidden form field. Here:

Code:
<html>
<head>
    <title>Testing</title>
    <script language="javascript">
    function doCountdown()
    {
        window.status = 'Refreshing in ... ' + timekeep + ' seconds';
        var tid = setTimeout('doCountdown();', 1000);
        if(timekeep > 0)
            timekeep -= 1;
        else
        {
            clearTimeout(tid);
            document.forms.redirect_form.submit();
        }
    }
    var timekeep = 5;
    doCountdown();
    </script>
</head>
<body>

<form action="myscript.php" method="get" name="redirect_form">
<input type="hidden" name="some_important_var" value="some_value" />
<input type="hidden" name="another_var" value="another_value" />
</form>

</body>
</html>
This will keep a countdown from 5 to zero, then auto submit the form. Auto-submitting the form will effectively create a redirect (which will be to the same page but with different values.). So all you have to do is plug the required variables into the form.
__________________

Please login or register to view this content. Registration is FREE
- Latest Articles:
Please login or register to view this content. Registration is FREE
,
Please login or register to view this content. Registration is FREE

--
Please login or register to view this content. Registration is FREE

Christopher is offline
Reply With Quote
View Public Profile
 
Old 07-06-2004, 05:54 PM thanks
milomedia's Avatar
Super Talker

Posts: 133
Location: durango, colorado
Trades: 0
Thanks so much, this rocks
__________________
_______________________________
Feeling down? listen to
Please login or register to view this content. Registration is FREE
milomedia is offline
Reply With Quote
View Public Profile Visit milomedia's homepage!
 
Reply     « Reply to More Efficient Mailing
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.29602 seconds with 12 queries