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, '[email protected]' );
I'm assuming that I will either need to update it to
$emails = array( $email, '[email protected], [email protected]' );
or
$emails = array( $email, '[email protected]','[email protected]' );
Any insight on which would be correct?
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, '[email protected]' );
I'm assuming that I will either need to update it to
$emails = array( $email, '[email protected], [email protected]' );
or
$emails = array( $email, '[email protected]','[email protected]' );
Any insight on which would be correct?
Looking at the snippet you provided the solution seems to be your last solution.
$emails = array( $email, '[email protected]','[email protected]' );
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.
EDIT
I see some comments regarding your first attempt:
$emails = array( $email, '[email protected], [email protected]' );
This is a valid array - however will pass the value of [email protected], [email protected]
instead of [email protected]
and [email protected]
as separate values - which by first glance is how the code is expecting additional email addresses.
Because the code snippet is
$emails = array( $email, '[email protected]' );
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, '[email protected], [email protected], [email protected]' );
Although I am not a fan of multiple emails on the 'to', would rather they were in a 'bcc' field.
$emails
being used for next? – socki03 Commented Oct 12, 2018 at 19:41