...

View Full Version : AUTO mailer



king2k5
01-11-2006, 09:12 PM
Hey, i was wondering if anyone knows a good Auto mailer code.. i just need a code so when i go to the webpage it will send all the e-mails, i dont need anything extra.. i got a list of emails in my database, and i need to send emails to everyone at once.. i got 3000+ emails.. so yea, it needs to be auto :P

king2k5
01-11-2006, 10:37 PM
someone help please...

Element
01-11-2006, 10:48 PM
for($i=0; $i<=$num; $i++) {

$email = mysql_result($result, $i, "email"); // The email in the database...
$subject = ""; // Apply your subject
$message =""; // Apply your message
$headers =""; // Apply your headers

if($i % 20) { echo "\n\n<p>Zzz...</p>\n\n"; sleep(10); }

if(mail($email, $subject, $message, $headers)) {
echo "<b>".number_format($i)."</b>: ".$email."<br>\n";
} else {
echo "<b>".number_format($i)."</b> FAILED: ".$email."<br>\n";
}

}

king2k5
01-11-2006, 11:11 PM
ok.. that sort of works.. that code only sends to the first person in the list.. i need it to send to all 3000 :P

king2k5
01-12-2006, 12:45 AM
nobody knows how to do this?

zis
01-12-2006, 01:56 AM
There's PHP list it's a complete newsletter engine.. but it has a good mail sending engine with reports time outs and failsafes. Give it a look here:
http://tincan.co.uk/phplist

king2k5
01-12-2006, 09:56 PM
thats way too complicated... i just want one easy script.. like..

$link = "SELECT * FROM mailinglist";
$res = mysql_query($link) or die(mysql_error());
$email = mysql_result($res,$i,"email");

$msg = "Dear player of Medieval: The Dark Ages,";
$msg.= "\n";
$msg.= "You have played the previous age with us, but this age you haven't signed up again.\n";
$msg.= "We invite you to come and play Medieval: The Dark Ages again.\n"; $msg.= "\n";
$msg.= "The Earth was young, but was without a leader, it was every man for himself. Mighty warriors fought for control over land, but destroyed everything in their paths. Build up your army to defend your base and pillage and plunder others. Mine for gold, then purchase a range of weapons and armour to help lead an assault on an enemy.\n";
$msg.= "\n";
$msg.= "http://www.medieval-tda.net/\n";
$msg.= "\n";
$msg.= "-Administration\n"; mail($retval['email'],"Medieval: The Dark Ages",$msg,"From: do-not-reply-".$emailnr."@medieval-tda.com");


But with an auto sender, so there would be somthing like while() at the end.. but im not sure what to do.. i just need a simple code...

Element
01-13-2006, 12:20 AM
$query = "SELECT * FROM mailinglist";
$result = mysql_query($query);
$num = mysql_num_rows($result);

for($i=0; $i<=$num; $i++) {

$email = mysql_result($result, $i, "email"); // The email in the database...
$subject = ""; // Apply your subject
$msg = "Dear player of Medieval: The Dark Ages,";
$msg.= "\n";
$msg.= "You have played the previous age with us, but this age you haven't signed up again.\n";
$msg.= "We invite you to come and play Medieval: The Dark Ages again.\n"; $msg.= "\n";
$msg.= "The Earth was young, but was without a leader, it was every man for himself. Mighty warriors fought for control over land, but destroyed everything in their paths. Build up your army to defend your base and pillage and plunder others. Mine for gold, then purchase a range of weapons and armour to help lead an assault on an enemy.\n";
$msg.= "\n";
$msg.= "http://www.medieval-tda.net/\n";
$msg.= "\n";
$msg.= "-Administration\n"; mail($retval['email'],"Medieval: The Dark Ages",$msg,"From: do-not-reply- ".$emailnr."@medieval-tda.com");
$headers =""; // Apply your headers

if($i % 20) { echo "\n\n<p>Zzz...</p>\n\n"; sleep(10); }

if(mail($email, $subject, $msg, $headers)) {
echo "<b>".number_format($i)."</b>: ".$email."<br>\n";
} else {
echo "<b>".number_format($i)."</b> FAILED: ".$email."<br>\n";
}

}

king2k5
01-13-2006, 01:32 AM
THANK you sooooooo much!!!!!! needless to say, that worked :D

king2k5
01-13-2006, 08:14 PM
ok.. a tiny little addon thing.. i couldnt finish sending them, as i have 3000 to send, i only got about half sent out... can i pick off where i left off? like where it says
$query = "SELECT * FROM mailinglist";
$result = mysql_query($query);
$num = mysql_num_rows($result);

could i add a where email='personsemail'???

Element
01-13-2006, 09:18 PM
No, because that will just fetch that persons row. What you need to do, is use the row number, which is safe to say is the number being outputted before the users email addross, if you can remember that you can add a option like, if isset($_GET['continue']) then you would trigger a seperate query instead of the original like:



if(isset($_GET['continue'])) {
$query = "SELECT * FROM mailinglist LIMIT ".$_GET['continue'].", COUNT(id)";
} else {
$query = "SELECT * FROM mailinglist";
}


Also, with this code you need to reset the for() statement to count from where its at, so we're do something like:



$start = $_GET['continue'] ? $_GET['continue'] : 0;


which should go under your $num variablne, then in the for() statement:



for($i=$start; $i<=$num; $i++) {


Not sure if that will work, you can give eit a try. $_GET['continue'] is the row where the script timed out.

fine
01-13-2006, 10:48 PM
Do you mean send bulk mails? Here is a tutorial send bulk mails through php (http://www.kidslovepc.com/php-tutorial/php-mail-bulk.shtml)

king2k5
01-14-2006, 03:54 PM
I did what you said element, but i got:

Warning: mysql_result(): supplied argument is not a valid MySQL result resource in /var/ftp/galacticoddessy.com/httpdocs/sendmailto.php on line 17
0:

line 17 is:


$email = mysql_result($start, $i, "email"); // The email in the database...



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum