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
-
Your Loan History Follows You: CIB Reports and Blacklisting in Nepal
Every time you apply for a loan from a bank or financial institution in Nepal, someone checks your record with the Credit Information Bur...
-
What a Share Trade Really Costs: Commission, Fees and Capital Gains Tax
You buy a share at Rs 500 and sell it at Rs 540. That's Rs 40 profit per share, right? Not quite. By the time the broker, SEBON, the ...
-
SIP in Nepal: Investing a Fixed Amount Every Month in Mutual Funds
A question I get a lot: "I don't have a big sum to invest. Is it even worth starting?" Yes. In fact, for most salaried peop...
-
Reading Your Salary Slip: Where Your Pay Goes Before It Reaches You
Your offer letter said Rs 60,000 a month. Your bank account says something smaller. Most people shrug and assume "tax," but a s...
-
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...
-
Buying Gold This Tihar? Jewellery Isn't the Same as Investing in Gold
In most Nepali families, gold isn't really a financial decision. It's a wedding gift, a mother's security, something you buy ...
-
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 ...
-
Small Scans, Big Leaks: Getting Control of Your Wallet and QR Spending
A few years ago, paying for tea meant opening your purse and seeing the notes get thinner. Now it's a scan, a beep, done. eSewa, Khal...
-
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...
-
Cloudflare Settings for Marketing Websites
Cloudflare is a widely-used content delivery network (CDN) and cybersecurity company that offers a suite of performance and security solutio...
No comments:
Post a Comment