Sending mail to many clients
include("connection.php");
if (!isset($_POST['submit'])):
?>
<html>
<head>
<title>Mailing List</title>
</head>
<body bgcolor="#D6DEE7">
<form method="post" action="<?=$_SERVER['PHP_SELF']?>">
<table width="471" border="0">
<tr>
<td colspan="2"><b><h2 align="center">MAILING LIST ADMIN</h2></b></td>
</tr>
<tr>
<td width="143">Send message to:</td>
<td width="318"><select name="to" size="1" style="background-color: #F7F7F7">
<option selected value="all">Entire School
<OPTION value="primary">primary
<OPTION value="lower_secondary">lower secondary
<OPTION value="secondary">secondary
</select></td>
</tr>
<tr>
<td>Title or Subject: </td>
<td><input name="subject" type=text maxlength=100 size=40></td>
</tr>
<tr>
<td valign="top">Message:</td>
<td><textarea wrap name="message" rows=10 cols=45></textarea></td>
</tr>
<tr>
<td colspan="2"><div align="center">
<input type=submit name="submit" value="SUBMIT">
</div></td>
</tr>
</table>
</form>
</body>
</html>
<?php else:
$to = $_POST['to'];
$subject = $_POST['subject'];
$message = $_POST['message'];
$country = $_POST['country'];
if ("all" == $to) {
$x = 1;
$hold = 50; // quantity of emails sent before 3 sec delay
$emails = mysql_query("SELECT email FROM schooldetails");
while ($sendemail = mysql_fetch_array($emails)) {
$email = $sendemail["email"];
mail($email, $subject,
$message, "From:Your name <you@whatever.com>");
$x++;
if($x == $hold) { // When $x is equal to $hold, a 3 sec delay will occur avoiding php to timeout
sleep(3);
$x = 0;
}
} // end of while loop
echo "send to all";
}
elseif ("primary" == $to) {
$x = 1;
$hold = 50; // quantity of emails sent before 3 sec delay
$emails = mysql_query("SELECT email FROM schooldetails where type_id='1'");
while ($sendemail = mysql_fetch_array($emails)) {
$email = $sendemail["email"];
mail($email, $subject,
$message, "From:Your name <you@whatever.com>");
$x++;
if($x == $hold) { // When $x is equal to $hold, a 3 sec delay will occur avoiding php to timeout
sleep(3);
$x = 0;
}
} // end of while loop
echo "send to primary";
}
elseif ("lowersecondary" == $to) {
$x = 1;
$hold = 50; // quantity of emails sent before 3 sec delay
$emails = mysql_query("SELECT email FROM schooldetails where type_id='2'");
while ($sendemail = mysql_fetch_array($emails)) {
$email = $sendemail["email"];
mail($email, $subject,
$message, "From:Your name <you@whatever.com>");
$x++;
if($x == $hold) { // When $x is equal to $hold, a 3 sec delay will occur avoiding php to timeout
sleep(3);
$x = 0;
}
} // end of while loop
echo "send to lower secondary";
}
elseif ("secondary" == $to) {
$x = 1;
$hold = 50; // quantity of emails sent before 3 sec delay
$emails = mysql_query("SELECT email FROM schooldetails where type_id='3'");
while ($sendemail = mysql_fetch_array($emails)) {
$email = $sendemail["email"];
mail($email, $subject, $message, "From:Your name <you@whatever.com>");
$x++;
if($x == $hold) { // When $x is equal to $hold, a 3 sec delay will occur avoiding php to timeout
sleep(3);
$x = 0;
}
} // end of while loop
echo "send to secondary";
}
?>
<html>
<head>
</head>
<body>
SUCCESS!
</body>
</html>
<?php endif; ?>
Sending mail to many clients, sending mail to according to group
Related posts
Popular posts
-
Damber Nepali Songs
Top & Famous Songs Aja Aakash Ma Euta Tara Tara Antim Palta Bhetna Aau Sabai Sathi Gaye Bigreko Manche Ma Ke Samjhi Khelyau Timro Pauju ...
-
ACKNOWLEDGEMENT and table of content of E-shopping
ACKNOWLEDGEMENT This report has been prepared for the Final Year Project on topic “E-shoppin...
-
Questions for boring minds
1) Without touching,how will you kill a Plant ? a) By Knife b) By Rope and Gun c) By Scolding d) None 2) I was in Dream. In Dream I visited ...
Featured Post
If Something Happened to You, Could Your Family Find Your Money?
Nobody likes this question, so let's get it over with quickly. If you were seriously ill or died tomorrow, would your family know whe...
Popular Posts
-
Questions for boring minds
1) Without touching,how will you kill a Plant ? a) By Knife b) By Rope and Gun c) By Scolding d) None 2) I was in Dream. In Dream I visited ...
-
ACKNOWLEDGEMENT and table of content of E-shopping
ACKNOWLEDGEMENT This report has been prepared for the Final Year Project on topic “E-shoppin...
-
Damber Nepali Songs
Top & Famous Songs Aja Aakash Ma Euta Tara Tara Antim Palta Bhetna Aau Sabai Sathi Gaye Bigreko Manche Ma Ke Samjhi Khelyau Timro Pauju ...
-
Click on the link and get the most beautiful templates to download for free
Click To download the tempalte 1
-
EPF, CIT and SSF: Where the Retirement Deduction on Your Payslip Goes
If you have a salaried job in Nepal, your payslip probably has a line that quietly takes a chunk of your pay before you see it. It might ...
-
Festival Spending Without the Hangover: Start Saving for Next Dashain Now
Dashain is just behind us and Tihar is a couple of weeks away. If you're like most Nepali households, this is the most expensive stre...
-
The main object of this lab is to be familiar with the DML(Data Manipulation Language)
DBMS LAB 4 The main object of this lab is to be familiar with the DML(Data Manipulation Language) Dele...
-
SIP in Equity Shares: How to Build a Long-Term Stock Investment Strategy in Nepal
When most people hear the term SIP (Systematic Investment Plan) , they immediately think of mutual funds. The idea is simple: invest a fixed...
-
Drupal JavaScripts to hide and show resources
{# 1. Main slider paragraph template #} {# File: templates/paragraph--slider-with-resources.html.twig #} <div class="slider-with-res...
-
Data Providers in ASP.net
Data Providers The most commonly used .NET data providers are described in the following sections. A. ...
No comments:
Post a Comment