Hi
I new! Anyone know how to create a mass mail to the membership list from database that the system can handle 9000-12000 membership list?
Can MySQL support huge data?
Can anyone show how to do a mass mail.
thank you.
Hi
I new! Anyone know how to create a mass mail to the membership list from database that the system can handle 9000-12000 membership list?
Can MySQL support huge data?
Can anyone show how to do a mass mail.
thank you.
yes mysql can handle pretty much any size database
I don't support SPAM, so I wont show it to you.
As much as I DON'T support SPAM, I'll help you a bit.
Just create a regular mail php script, and then loop through all the times in the database.
That way will give you a personal message per person.
Another way is to just loop through all the names/addresses in the database, and set them to a running variable, and use that as the TO: field.
I.e.
<?php
// Define variables
$to = "";
$from = "me@mywebsite.com";
$subject = "I DUNNO";
$Message = "Whatever you want";
$name = "Brett";
$header = 'FROM: '$name.'<'.$from.'>';
// Do your MySQL Stuff Here
$dbc = mysql_connect("localhost", "username", "password");
mysql_select_db("Datbase_1");
$query = "SELECT * FROM `db_emails`";
$result = mysql_query($query, $dbc);
/* This is where things differ.
If you dont' mind everyone seeing who you're sending to, do this: */
while($disp = mysql_fetch_array($result)){
$to .= $disp['address'];
}
mail($to, $subject, $message, $header;
/* If you want it to look personalized, do this: */
while($disp = mysql_fetch_array($result)){
mail($disp['address'], $subject, $message, $header);
}
Hope that helps.
I don't support spam, so if that's what you're going to use this for, please don't email me.
~Brett
not spam..only paid members will get the information via mail mass.
And you could also search these forums on the subject of bulk mail.
I have made my own mass mailer. You may need to change some things..
(email.php)
<html>
<body>
<center>
<form action="http://YOUR DOMAIN/emailusers.php" method="post">
<table width="90%" cellspacing="2" cellpadding="1">
<tr>
<td width="100%" align="center" colspan="2">
Email Users
</td>
</tr>
<tr>
<td width="100%" align="center" colspan="2">
</td>
</tr>
<tr>
<td width="50%" align="center">
Subject
</td>
<td width="50%" align="center">
<input type="text" name="subject">
</td>
</tr>
<tr>
<td width="50%" align="center">
Message
</td>
<td width="50%" align="center">
<textarea rows="5" cols="20" name="message"></textarea>
</td>
</tr>
<tr>
<td width="100%" align="center" colspan="2">
</td>
</tr>
<tr>
<td width="50%" align="center">
<input type="submit" value="Submit">
</td>
<td width="50%" align="center">
<input type="reset" value="Reset">
</td>
</tr>
</table>
</form>
</center>
</body>
</html>
(emailusers.php)
<html>
<body>
<center>
<?php
$user = "MySQL Username";
$pass = "MySQL Usernames Password";
$db = "Database to pull emails";
$query = mysql_query("SELECT * FROM Users");
while($row = mysql_fetch_array($query))
{
$to = $row['email'];
$subject = htmlspecialchars(addslashes($_POST['subject']));
$message = htmlspecialchars(addslashes($_POST['message']));
mail($to, $subject, $message,"From: AutoMailer@YOUR DOMAIN");
}
$num = mysql_num_rows($query);
echo $num." users have been emailed.";
?>
</center>
</body>
</html>
once again, there ARE a few things you may need to change - This script is made by me and you can customize the message into a post
Seems like it would work. I might not use $POST, I would use $REQUEST to be on the safe side.
~Brett
As Weedpacket tried to point out, looping through a recordset and creating a mail process for every address is a bad idea. Have a search for bulk mailers that use sockets, or check out PEAR's various mailers.
Shrike,
Out of curiousity, why is looping through a bad idea? Would it take too long, or would it put extra strain in the cpu?
~Brett
I imagine a bit of both.
Open a connection to the mail server
Configure
Send one email
Wait for the response
Close the connection to the mail server
Open a connection to the mail server
Configure
Send one email
Wait for the response
Close the connection to the mail server
Open a connection to the mail server
Configure
Send one email
Wait for the response
Close the connection to the mail server
Open a connection to the mail server
Configure
Send one email
Wait for the response
Close the connection to the mail server
....
When you have a bundle of letters to post physically, do you post them one at a time - walking to the mailbox with one letter, dropping it in, then walking back to get the next? No? Why not?
l would reccommend the script I posted above - it willemail all the users and takes up the less time (Unless your server is slow )
Originally posted by robert_w_ark
takes up the less time
Than what?
Robert is saying that comperatively, my script versus his, his would be faster. Not much faster, but faster.
It's also a possiblity to do a foreach() function. May be the same speed as Roberts. YOu would do that as follows:
<?php
$query = "SELECT Email FROM `emails`";
$result = mysql_query($result);
$display = mysql_fetch_array($result);
foreach($display as $address){
mail($address, $subject, $message, $headers);
}
Not 100% sure that would be faster, but is much less code. But basically what you would be doing is putting an array together of the 9k emails, and then shooting them off.
It may even be better to list all of them in a variable:
$email_to = '';
while($display = mysql_fetch_array($result)){
$email_to .= $display['Email'].'; ';
}
And include a header that hides all the email addresses, and only shows a generic list name as the To: field.
To: Need not contain the recipients address, but when in the header portion of the email, the To: field is over-ridden with the To: header's value. So if you say:
To: My Email List
and send it to 9k recipients, each person would get an email and in the To: column/line it would say "My Email List" and NOT the email address.
~Brett
I still think it would be a lot better to skip using mail() and do SMTP directly.
Its still got the idea of what should be avoided when bulk mailing. Mail will open a connection send close and looping just continues this. Some scripts like so will timeout after a while especially if you have 10s of thousands signed up.
There could be a problem using the foreach() function to email 9k+ emails at once - It may clog the pipe and crash the server - But its up to you The script I posted earlier will send a custom message that you can type
Hey Weed,
How would you use the SMTP directly?
~ Brett