phlash2k1 Posted February 27, 2007 Share Posted February 27, 2007 I am trying to send emails to players from my mysql database according to which drop down selection is made. The first dropdown is to email all players in the database and the 2nd selection is emailing by teams. Any help will be greatly appriciated. I am fairly new to php mysql Nothing happens. No errors. I just don't receive an email here is the code: <?php include("dbconnection.php"); if (!isset($_POST['submit'])): ?> <html> <head> <title>Football League Email</title> </head> <body> <form method="post" action="<?=$_SERVER['PHP_SELF']?>"> <table align="center" bgcolor="#D6DEE7" border="0" cellpadding="0" cellspacing="0"> <tr> <td align="center"> <b><h2>MAILING LIST ADMIN</h2></b> Send message to: <select name="to" size="1" style="background-color: #F7F7F7"> <option selected value="all">All Players <option value="notall">By Team </select> Team: <select name="team" size="5"> <OPTION value="0003">Boudreaux <OPTION value="0004">Brazil </select> Title or Subject: <input name="subject" type=text maxlength=100 size=40> Message: <textarea wrap name="message" rows=10 cols=45></textarea> <input type=submit name="submit" value="SUBMIT"> </td> </tr> </table> </form> </body> </html> <?php else: $to = $_POST['to']; $subject = $_POST['subject']; $message = $_POST['message']; $team = $_POST['team']; if ("all" == $to) { $x = 1; $hold = 50; // quantity of emails sent before 3 sec delay $emails = mysql_query("SELECT email FROM players"); while ($sendemail = mysql_fetch_array($emails)) { $email = $sendemail["email"]; mail($email, $subject,$message, "From:League Admin <myemail@myemail.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 } else { $byteam = mysql_query("SELECT email FROM players WHERE teamid = '$team'"); while ($countmail = mysql_fetch_array($byteam)) { $email = $countmail["email"]; $okemail = mail($email, $subject,$message, "From:League Admin <myemail@myemail.com>")or die("Could not send mail"); $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 } ?> <html> <head> </head> <body> SUCCESS! </body> </html> <?php endif; ?> Quote Link to comment Share on other sites More sharing options...
spfoonnewb Posted February 27, 2007 Share Posted February 27, 2007 You never actually send the email, you just set a variable: $okemail = mail($email, $subject,$message, "From:League Admin <myemail@myemail.com>")or die("Could not send mail"); Should be: mail($email, $subject, $message, "From:League Admin <myemail@myemail.com>")or die("Could not send mail"); Quote Link to comment Share on other sites More sharing options...
btherl Posted February 27, 2007 Share Posted February 27, 2007 Actually, setting the variable won't interfere with sending the email. Phlash, have you tried a simple script which sends an email only, without any added headers? Does that fail too? Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.