I inherited a WordPress site that has a lot of custom coding that appears to be Bootstrap. A contact form is coded in a PHP file and the client would like to add a couple more email addresses for submissions to be sent to.

I've found the code for sending the email, but I want to make sure that I update it correctly and not break it. Here is the line of code:

$emails = array( $email, 'myemail@me.com' );

I'm assuming that I will either need to update it to

$emails = array( $email, 'myemail@me.com, anotheremail@me.com' );


$emails = array( $email, 'myemail@me.com','anotheremail@me.com' );

Any insight on which would be correct?

  • What is $emails being used for next? – socki03 Oct 12 '18 at 19:41
  • Seems to me that the first one would be correct. But there's really no way to tell without knowing how the rest of the code works. Good chance your first solution will work though. – Pim Oct 12 '18 at 19:42

Looking at the snippet you provided the solution seems to be your last solution.

$emails = array( $email, 'myemail@me.com','anotheremail@me.com' );

Sending an array of emails, the first one ($email) being the dynamic email. The second and third would be hard coded values.

This is assuming the email handler is ready to accept an array of emails to mail to.


I see some comments regarding your first attempt:

$emails = array( $email, 'myemail@me.com, anotheremail@me.com' );

This is a valid array - however will pass the value of myemail@me.com, anotheremail@me.com instead of myemail@me.com and anotheremail@me.com as separate values - which by first glance is how the code is expecting additional email addresses.


Because the code snippet is

$emails = array( $email, 'myemail@me.com' );

Then I assume the second parameter of the array is the destination email address. Assuming that you don't care if all email addresses are exposed to the recipient (because they are all in the 'to' field), then this would work

$emails = array( $email, 'myemail@me.com, another@here.com, metoo@there.com' );

Although I am not a fan of multiple emails on the 'to', would rather they were in a 'bcc' field.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.