Zepo. Posted December 8, 2007 Share Posted December 8, 2007 This isnt working for some reason, and im not sure if you can email in loops like this...... Loop $emailq=mysql_query("SELECT name,email FROM teams"); while(list($name,$email)=mysql_fetch_row($emailq)){ $email[toname] ="$name"; $email[toemail] ="$email"; $email[subject] ="$send[subject]"; $email[fromname] ="{$_SESSION['rights']}"; $email[fromemail] ="$config[sitemail]"; $email[replyname] ="$name"; $email[replyemail] ="$email"; $email[body] ="$send[body]"; email($email); $sent.="Sending To $name..........Sent<br />"; } Email Function //E-Mail Function function email($email){ mail("$email[toname] <$email[toemail]>","$email[subject]","$email[body]", "From: $email[fromname] <$email[fromemail]>\nReply-To: $email[replyname] <$email[replyemail]>\nContent-type: text/plain\nX-Mailer: PHP/" . phpversion()); } No errors. Link to comment https://forums.phpfreaks.com/topic/80824-emailing/ Share on other sites More sharing options...
Crew-Portal Posted December 8, 2007 Share Posted December 8, 2007 Your function is calling a variable that gets defined in the actual code try: <?php $emailq=mysql_query("SELECT name,email FROM teams"); function email($email){ mail("$email[toname] <$email[toemail]>","$email[subject]","$email[body]", "From: $email[fromname] <$email[fromemail]>\nReply-To: $email[replyname] <$email[replyemail]>\nContent-type: text/plain\nX-Mailer: PHP/" . phpversion()); } while(list($name,$email)=mysql_fetch_row($emailq)){ $email[toname] ="$name"; $email[toemail] ="$email"; $email[subject] ="$send[subject]"; $email[fromname] ="{$_SESSION['rights']}"; $email[fromemail] ="$config[sitemail]"; $email[replyname] ="$name"; $email[replyemail] ="$email"; $email[body] ="$send[body]"; email($email); $sent.="Sending To $name..........Sent<br />"; } ?> Link to comment https://forums.phpfreaks.com/topic/80824-emailing/#findComment-410015 Share on other sites More sharing options...
Crew-Portal Posted December 8, 2007 Share Posted December 8, 2007 BTW I checked out your website and man it looks nice! Link to comment https://forums.phpfreaks.com/topic/80824-emailing/#findComment-410017 Share on other sites More sharing options...
Zepo. Posted December 8, 2007 Author Share Posted December 8, 2007 Thank you! Well the two functions are in two different files....so i cant do it like that. Link to comment https://forums.phpfreaks.com/topic/80824-emailing/#findComment-410031 Share on other sites More sharing options...
trq Posted December 9, 2007 Share Posted December 9, 2007 You have alot of code there that would be generating syntax warnings, and also absolutely no error handling. <?php if ($emailq = mysql_query("SELECT name,email FROM teams")) { if (mysql_num_rows($emailq)) { while(list($name,$email)=mysql_fetch_row($emailq)){ $email['toname'] =$name; $email['toemail'] =$email; $email['subject'] =$send['subject']; $email['fromname'] ={$_SESSION['rights']; $email['fromemail'] =$config['sitemail']; $email['replyname'] =$name; $email['replyemail'] =$email; $email['body'] =$send['body']; if (email($email)) { $sent.="Sending To $name..........Sent<br />"; } } } } Next, your email function should look like.... <?php function email($email){ return mail("{$email['toname']} <{$email['toemail']}>",$email['subject'],$email['body'], "From: {$email['fromname']} <{$email['fromemail']}>\nReply-To: {$email['replyname']} <{$email['replyemail']}>\nContent-type: text/plain\nX-Mailer: PHP/" . phpversion()); } ?> Link to comment https://forums.phpfreaks.com/topic/80824-emailing/#findComment-410034 Share on other sites More sharing options...
trq Posted December 9, 2007 Share Posted December 9, 2007 Also, ps. You are getting no errors becuas eyou obviously have error reporting switched off, or set too low. Otherwise all those syntax warnings I pointed out would show up. Make sure error reporting and display errors are on while you develop your scripts. Link to comment https://forums.phpfreaks.com/topic/80824-emailing/#findComment-410035 Share on other sites More sharing options...
Zepo. Posted December 9, 2007 Author Share Posted December 9, 2007 My server is weird. I never get any php warnings, and instead of getting php errors, i get a 500 error, which had made it very hard to develop on this server. Link to comment https://forums.phpfreaks.com/topic/80824-emailing/#findComment-410038 Share on other sites More sharing options...
Zepo. Posted December 9, 2007 Author Share Posted December 9, 2007 Also the code still doesnt work, you dont have the email function anywhere in your script... i put it in, and no luck... Link to comment https://forums.phpfreaks.com/topic/80824-emailing/#findComment-410154 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.