Jump to content

Recommended Posts

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;

 

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;
?>

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'] ; 

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;
?>

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.