View Full Version : mass email script
nomirock
Jul 31st 2007, 3:00 am
i need code for making a mass mailing script with which i can send more than 1 email to an email address.
uniqueasitis
Jul 31st 2007, 3:08 am
here are some scripts that may help solve your problem
http://www.sitescripts.com/PHP/Email_(Mailing_Lists)/
HuggyCT2
Jul 31st 2007, 4:23 am
Where are the emails stored?
If they are in mysql you can loop the results and send the mails out like that.
Someting like.
HTML Form
<h4>Mass mail form</h4>
<form action="" name="mass_email" method="post">
<p>Subject of Mail: <input type="text" name="subject"></p>
<p>Message to Send: <input type="text" name="message"></p>
<p><input type="submit" name="send" value="Send the mass mail"></p>
</form>
<?php
if($_POST['send'])
{
/***
Connections Information here
***/
$result = mysql_query("SELECT * FROM email");
// gets all the emails from the db
$total = @mysql_num_rows($result);
// total emails in db
if($total==0)
echo "No emails where found";
}else{
$i=0;
// loops the emails
while($i<$total)
{
$subject = $_POST['subject'];
$message = $_POST['message'];
$to = mysql_result($result, $i, 'email');
mail($to, $subject, $message) or die ("Mail failed");
echo "Sent Mail to $to<br />";
$i++;
}
}
echo "Sent $i emails in total";
}
?>
I just coded that in the quick reply havent tested it but it should work fine, this is just to show you how to use mysql and php to make a simple mass mailer, you would need to make a database have the fields I made etc to get it to work.
nico_swd
Jul 31st 2007, 4:36 am
^ The problem with that is, that your server's DNS is going to get blocked quick, if you have a lot of users or send a lot of emails. You should use a queue. Send a few mails... wait a while,... send a few more, and so on...
HuggyCT2
Jul 31st 2007, 5:54 pm
It was to show how you would go about doing a mass mail, I think setting stages and making it more complicated is not wise for a novice.
nomirock
Jul 31st 2007, 8:54 pm
Thanx for your help people i have understood it now
postcd
Dec 16th 2007, 2:51 am
^ The problem with that is, that your server's DNS is going to get blocked quick, if you have a lot of users or send a lot of emails. You should use a queue. Send a few mails... wait a while,... send a few more, and so on...
How to do it??please
Kaizoku
Dec 16th 2007, 3:57 am
easiest way is to use the sleep(); function, if you sleep too much you might die :p
sleep(1800); // delay the script for 30 minutes
The harder and more efficient way is to use the sendmail or postfix server to queue the emails for you. Another way is to split up the database table into parts using
SELECT * FROM emails LIMIT 0,100
SELECT * FROM emails LIMIT 100,100
SELECT * FROM emails LIMIT 200,100 ... and so on...
vBulletin® v3.6.8, Copyright ©2000-2008, Jelsoft Enterprises Ltd.