matt.sisto Posted May 21, 2009 Share Posted May 21, 2009 I have been trying to figure it out but I can't, any help appreciated. $sql = "SELECT email_address FROM consultant WHERE con_id = '$con_id1'"; $result=mysql_query($sql); $to = mysql_result($result, 0, 0); $sql = "SELECT email_address FROM consultant WHERE con_id = '$con_id2'"; $result=mysql_query($sql); $to.= mysql_result($result, 0, 0); $sql = "SELECT email_address FROM consultant WHERE con_id = '$con_id2'"; $result=mysql_query($sql); $to.= mysql_result($result, 0, 0); $sender = 'admin@salmonsreach.org'; $headers = "SRC: Administrative Team"; $message = "We would like to notify you that a client has booked an appointment with you. Thanks and Regards, SRC Administrative Team."; $message.= "<br /> Event date: ".$event_start."\n"; $message.= "<br /> Event end date: ".$end_date."\n"; $message.= "<br /> Service: ".$service."\n"; $message.= "<br /> Start time: ".$start_time."\n"; $message.= "<br /> Address: ".$address_first_line."\n"; $message.= "<br /> Post Code: ".$post_code."\n"; mail($to, $sender, $message, $headers); Thanks and regs. Quote Link to comment https://forums.phpfreaks.com/topic/159182-whats-wrong-with-my-mail-script/ Share on other sites More sharing options...
roopurt18 Posted May 21, 2009 Share Posted May 21, 2009 Look carefully at what you're telling your program to do: <?php $sql = "SELECT email_address FROM consultant WHERE con_id = '$con_id1'"; $result=mysql_query($sql); $to = mysql_result($result, 0, 0); // $to = 'asdf@asdf.com'; $sql = "SELECT email_address FROM consultant WHERE con_id = '$con_id2'"; $result=mysql_query($sql); $to.= mysql_result($result, 0, 0); // $to = $to . 'foobar@foobar.com' // ==> $to = 'asdf@asdf.com' . 'foobar@foobar.com' // ==> $to = 'asdf@asdf.comfoobar@foobar.com' $sql = "SELECT email_address FROM consultant WHERE con_id = '$con_id2'"; $result=mysql_query($sql); $to.= mysql_result($result, 0, 0); // $to = $to . 'qwerty@qwerty.com' // ==> $to = 'asdf@asdf.comfoobar@foobar.com' . 'qwerty@qwerty.com' // ==> $to = 'asdf@asdf.comfoobar@foobar.comqwerty@qwerty.com' $sender = 'admin@salmonsreach.org'; $headers = "SRC: Administrative Team"; $message = "We would like to notify you that a client has booked an appointment with you. Thanks and Regards, SRC Administrative Team."; $message.= "<br /> Event date: ".$event_start."\n"; $message.= "<br /> Event end date: ".$end_date."\n"; $message.= "<br /> Service: ".$service."\n"; $message.= "<br /> Start time: ".$start_time."\n"; $message.= "<br /> Address: ".$address_first_line."\n"; $message.= "<br /> Post Code: ".$post_code."\n"; // $to contains: 'asdf@asdf.comfoobar@foobar.comqwerty@qwerty.com' // Does $to look like a valid email address to you? mail($to, $sender, $message, $headers); ?> Quote Link to comment https://forums.phpfreaks.com/topic/159182-whats-wrong-with-my-mail-script/#findComment-839497 Share on other sites More sharing options...
matt.sisto Posted May 21, 2009 Author Share Posted May 21, 2009 Well when you put it like that no, but how can I break it up? Quote Link to comment https://forums.phpfreaks.com/topic/159182-whats-wrong-with-my-mail-script/#findComment-839498 Share on other sites More sharing options...
Maq Posted May 21, 2009 Share Posted May 21, 2009 You should refer to the manual for proper format - mail. user@example.com, anotheruser@example.com, anotheruser@example.com, anotheruser@example.com Quote Link to comment https://forums.phpfreaks.com/topic/159182-whats-wrong-with-my-mail-script/#findComment-839499 Share on other sites More sharing options...
roopurt18 Posted May 21, 2009 Share Posted May 21, 2009 Change all instances of: $to.= mysql_result($result, 0, 0); to: $to.= ', ' . mysql_result($result, 0, 0); You should only make two changes based on the code you presented, i.e. you don't change the line: $to = mysql_... Also it's really better if you throw just one query at the database rather than three, but you can work on that after you have the initial approach working. Quote Link to comment https://forums.phpfreaks.com/topic/159182-whats-wrong-with-my-mail-script/#findComment-839501 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.