Mandolin Posted July 15, 2011 Share Posted July 15, 2011 Hoping for some help with a small issue. I'm not a programmer but I simply need to update an existing php contact form page. A portion of the code currently looks like what I've pasted below (actual names & email addresses changed). My issue is that I need this email to be delivered to 3 recipients. How do I add a recipient, for example if I want this to go to Name1, Name2 and Name3. Any help is greatly appreciated! $emails = array("name1" => "[email protected]", "name2" => "[email protected]", "name3" => "[email protected]", "name4" => "[email protected]"); switch ($Dept) { case "Customer Service": $email_to = $emails['name1'] . ", " . $emails['name2']; break; Quote Link to comment https://forums.phpfreaks.com/topic/242061-seeking-help-with-emailing-multiple-addresses-in-php-contact-form/ Share on other sites More sharing options...
gristoi Posted July 15, 2011 Share Posted July 15, 2011 try: <?php $emails = array("name1" => "[email protected]", "name2" => "[email protected]", "name3" => "[email protected]", "name4" => "[email protected]"); switch ($Dept) { case "Customer Service": $email_to = $emails['name1'] . ", " . $emails['name2']. ",".$emails['name3'] ; break; ?> Quote Link to comment https://forums.phpfreaks.com/topic/242061-seeking-help-with-emailing-multiple-addresses-in-php-contact-form/#findComment-1243076 Share on other sites More sharing options...
TeNDoLLA Posted July 15, 2011 Share Posted July 15, 2011 It might be good idea to use implode there if the amount of emails can be dynamic. E.g coming from database by certain criteria. Or if there is just huge amount of emails. $email_to = implode($emails, ','); instead of $email_to = $emails['name1'] . ", " . $emails['name2']. ",".$emails['name3'] ; Quote Link to comment https://forums.phpfreaks.com/topic/242061-seeking-help-with-emailing-multiple-addresses-in-php-contact-form/#findComment-1243088 Share on other sites More sharing options...
Mandolin Posted July 15, 2011 Author Share Posted July 15, 2011 Worked like a charm, thanks so much! try: <?php $emails = array("name1" => "[email protected]", "name2" => "[email protected]", "name3" => "[email protected]", "name4" => "[email protected]"); switch ($Dept) { case "Customer Service": $email_to = $emails['name1'] . ", " . $emails['name2']. ",".$emails['name3'] ; break; ?> Quote Link to comment https://forums.phpfreaks.com/topic/242061-seeking-help-with-emailing-multiple-addresses-in-php-contact-form/#findComment-1243091 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.