computel Posted July 14, 2010 Share Posted July 14, 2010 php email problem getting email address from mysql Here is the email i see sitting on my hosting server. as you can see the to: field is blank and not getting the emails from mysql database. Return-path: <> Envelope-to: [email protected] Delivery-date: Wed, 14 Jul 2010 15:47:32 -0500 Received: from mailnull by chevette.websitewelcome.com with local (Exim 4.69) id 1OZ8rc-0000WU-IV for [email protected]; Wed, 14 Jul 2010 15:47:32 -0500 Auto-Submitted: auto-replied From: Mail Delivery System <[email protected]> To: [email protected] Subject: Mail failure - no recipient addresses Message-Id: <[email protected]> Date: Wed, 14 Jul 2010 15:47:32 -0500 A message that you sent contained no recipient addresses, and therefore no delivery could be attempted. ------ This is a copy of your message, including all the headers. ------ To: Subject: test The user signs up and thier email_address & name get stored in the games_newsletter table. here is the php code that sends the emails out. <? require_once("../conn.php"); require_once("../includes.php"); require_once("access.php"); require_once("AdminNavigation.php"); if(isset($_POST[s1])) { $q2 = "select * from games_newsletter "; $r2 = mysql_query($q2) or die(mysql_error()); while($a2 = mysql_fetch_array($r2)) { $to = $a2[email]; $subject = $_POST[sub]; $message = $_POST[MyMessage]; $headers = "MIME-Version: 1.0\n"; $headers .= "Content-type: text/plain; charset=iso-8859-1\n"; $headers .= "Content-Transfer-Encoding: 8bit\n"; $headers .= "From: $_SERVER[HTTP_HOST]$dir <$aset[ContactEmail]>\n"; $headers .= "X-Priority: 1\n"; $headers .= "X-MSMail-Priority: High\n"; $headers .= "X-Mailer: PHP/" . phpversion()."\n"; mail($to, $subject, $message, $headers); $i++; } $error = "$i messages was sent"; } //get the number of registered for the newsletter $q2 = "select count(*) from games_newsletter"; $r2 = mysql_query($q2) or die(mysql_error()); $a2 = mysql_fetch_array($r2); if($a2[0] == 0) { echo "<br><br><center><span class=RedLink>There are no registered members, yet!</span></center>"; exit(); } ?> <script> function CheckMail() { if(document.f1.sub.value=="") { alert('Enter the newsletter subject line, please!'); document.f1.sub.focus(); return false; } if(document.f1.MyMessage.value=="") { alert('Enter the newsletter text, please!'); document.f1.MyMessage.focus(); return false; } } </script> <center> <span class=BlackLink> There are <?=$a2[0]?> newsletter subscribers. </span> </center> <br> <form method=post onsubmit="return CheckMail();" name=f1> <table align=center width=500> <tr> <td></td> <td><b>Newsletter</b><br><?=$error?></td> </tr> <tr> <td align=right>Subject:</td> <td><input type=text name=sub size=36></td> </tr> <tr> <td align=right valign=top>Message:</td> <td><textarea name=MyMessage rows=10 cols=50></textarea></td> </tr> <tr> <td> </td> <td><input type=submit name=s1 value="Send" class="sub1"></td> </tr> </table> </form> <? require_once("admin_footer.php"); ?> [/sub] I have spent the whole day on this and it doesn't work. I have a members email and it sends out the emails no problem and from what I could see the only diffents in the two php files were the select from * tables and that is it. thank you in advance Link to comment https://forums.phpfreaks.com/topic/207770-php-email-problem-getting-email-address-from-mysql/ Share on other sites More sharing options...
radar Posted July 14, 2010 Share Posted July 14, 2010 have you tried mysql_fetch_assoc instead of mysql_fetch_array? Link to comment https://forums.phpfreaks.com/topic/207770-php-email-problem-getting-email-address-from-mysql/#findComment-1086130 Share on other sites More sharing options...
computel Posted July 15, 2010 Author Share Posted July 15, 2010 I'm new to php and this is the first script I looked at and trying to get it to work. how would I go about doing this. Thanks Link to comment https://forums.phpfreaks.com/topic/207770-php-email-problem-getting-email-address-from-mysql/#findComment-1086171 Share on other sites More sharing options...
computel Posted July 15, 2010 Author Share Posted July 15, 2010 Figured it out myself. all I did was change the email_address to email in the games_newsletter table and made a change to the subscription form and it all worked out. strange I have no programming or PHP experience but it goers to show sometimes just trying things can fix it. Link to comment https://forums.phpfreaks.com/topic/207770-php-email-problem-getting-email-address-from-mysql/#findComment-1086199 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.