|
-
Sep 24th, 2006, 09:14 PM
#1
Thread Starter
Hyperactive Member
Using Mail() to mass email
What would be the best way to mass email? Using Mail()? If so is there a way to ease the lag on the server?
-
Sep 25th, 2006, 08:05 PM
#2
Thread Starter
Hyperactive Member
Re: Using Mail() to mass email
-
Sep 25th, 2006, 08:22 PM
#3
Fanatic Member
Re: Using Mail() to mass email
Why are you trying to mass email?
-
Sep 25th, 2006, 08:32 PM
#4
Thread Starter
Hyperactive Member
Re: Using Mail() to mass email
for a newsletter that visitors have signed up for.
-
Sep 25th, 2006, 08:50 PM
#5
Fanatic Member
Re: Using Mail() to mass email
My suggestion is to send them 100 mail address apart that way the script doesn't time out.
Like send 100 emails, refresh the page then do the next 100.
-
Sep 25th, 2006, 09:48 PM
#6
Thread Starter
Hyperactive Member
Re: Using Mail() to mass email
how would you do this programmicaly? so the end user wouldn't have to do anything.
-
Sep 25th, 2006, 11:37 PM
#7
Re: Using Mail() to mass email
I recently made a PHP script that opened my fonts folder and made an image of each font writing the same sample text and then saving it to a predetermined directory, and also logged its ID, filename and date into a MySQL database. Because of the amount of time it would take to create 2000+ images, I made it run 300 at a time. I didn't make it fully-automated, but that's not to say that it cannot be done. This is a sample from the script I was talking about, you'll have to try to adapt it to what you're doing.. I've added some comments to try to explain it a little.
PHP Code:
<?
//check if the user has "started" yet
if(isset($_GET['start']) && is_numeric($_GET['start']) && $_GET['start'] >= 0){
$fonts = array("this is just", "some samples", "because my array", "was populated with", "a readdir()",
"this is just", "some samples", "because my array", "was populated with", "a readdir()",
"this is just", "some samples", "because my array", "was populated with", "a readdir()",
"this is just", "some samples", "because my array", "was populated with", "a readdir()",
"this is just", "some samples", "because my array", "was populated with", "a readdir()",
"this is just", "some samples", "because my array", "was populated with", "a readdir()",
"this is just", "some samples", "because my array", "was populated with", "a readdir()",
"this is just", "some samples", "because my array", "was populated with", "a readdir()",
"this is just", "some samples", "because my array", "was populated with", "a readdir()");
$start = $_GET['start'];
$increment = 20; //number of things to process per step
$max = $increment;
if(($start + $max) > count($fonts)) $max = count($fonts);
$addmax = $start;
if($max == count($fonts)) $addmax = 0;
for($i = $start; $i < ($addmax+$max); $i++){
//send your emails, you will have to have addresses in an array so that you can
//call them using $arrayname[$i] (the array i am using in this case is $fonts)
echo $i . " done - ";
}
?>
<a name="b"></a>done processing fonts <?=$start + 1;?> to <?=$addmax + $max;?>.
<?
//make a link for the next step
if(($start + $increment) < count($fonts)){
$endproc = $start + ($increment * 2);
if($endproc > count($fonts)) $endproc = count($fonts);
?>
<a href="?start=<?=$start + $increment;?>#b">>> process fonts <?=$start + $increment + 1;?> to <?=$endproc;?></a>
<? }else{ ?>
<a name="b"><b></a>done processing <?=count($fonts);?> fonts</b>
<?
}
}else{ //user has NOT started yet, so just give them a link/make a form to start
echo '<a href="?start=0">start now</a>';
}
?>
I grabbed all the useful stuff and put it together and made sure it worked (and also created a sample array, and changed the increment from 300 to 40 because, frankly, I didn't want to make an array with over 300 elements just to show you it worked!) This code will run AS-IS, and to give you an idea of it and to show you it working, I uploaded it here.
Now, you can either use this to create 300 different mail() calls every loop, or do a mail() only after the for() is finished and use the for() to populate a variable with 300 different emails, seperating each email with a semi-colon to represent multiple people (i'm fairly sure you can do this, although i'm not positive because i haven't used mail() for a while, and never tried to do it for multiple people)
Now, to make it automated all you really need to do is eliminate any output that it's giving throughout the script (like the echoing in the for() loop) and add a header() that has a Location: url, the URL being the URL in the "next" link. Without testing it, I would say that should work fine. An alternative if it doesn't, is to use a <meta> tag after finished processing that refreshes to the next page, or even a JavaScript that redirects, depending on your browser (some Gecko browsers, to my knowledge, don't use the meta redirect tags correctly, but the JavaScript call is a hack to redirect them)
Oh, and a shameless plug, if anyone wanted to see my font database, you can view it here! Overall, it's useless, but I thought it would be a neat thing to do.
Last edited by kows; Sep 25th, 2006 at 11:41 PM.
-
Sep 27th, 2006, 10:09 PM
#8
Addicted Member
Re: Using Mail() to mass email
Hmmm, this sounds suspicious because no one referres to a newsletter as being mass mailing. Sounds kinda malicious, can you point to your site that has proof on it of some sort, cause mass mailing is actually against the law, unless of course for a newsletter.
-
Sep 27th, 2006, 10:56 PM
#9
Re: Using Mail() to mass email
actually, I refer to it as mass mailing, and I'm not a spammer. Saying it's a newsletter is the common person's outlook on it, mass mailing is the way a programmer might look at it.
-
Sep 28th, 2006, 04:48 AM
#10
Re: Using Mail() to mass email
We had this very problem about two months back. Search this forum for mail and timeout.
All the buzzt
 CornedBee
"Writing specifications is like writing a novel. Writing code is like writing poetry."
- Anonymous, published by Raymond Chen
Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|