You might want to change the recipients of the email based on a select menu value chosen by the form user. To do this you will need to change the recipients array depending on which value was chosen. In process.php replace the existing line containing $config['recipients']
with the code below.
123 4 5 6 7 8 910 11 12 13 14 15 1617 18 19 20 21 22 23 24 25 26 27 28 29 30 31 | switch($_POST['subject']) { case 'General enquiry': $config['recipients'] = array( 'email1@example.com', 'email2@example.com', 'email3@example.com' ); break; case 'Sales enquiry': $config['recipients'] = array( 'email4@example.com', 'email5@example.com', 'email6@example.com' ); break; case 'Support enquiry': $config['recipients'] = array( 'email7@example.com', 'email8@example.com', 'email9@example.com' ); break; default: // These will be the recipients if the subject does not match any above $config['recipients'] = array( 'email1@example.com', 'email4@example.com', 'email7@example.com' ); break; } |
switch($_POST['subject']) { case 'General enquiry': $config['recipients'] = array( 'email1@example.com', 'email2@example.com', 'email3@example.com' ); break; case 'Sales enquiry': $config['recipients'] = array( 'email4@example.com', 'email5@example.com', 'email6@example.com' ); break; case 'Support enquiry': $config['recipients'] = array( 'email7@example.com', 'email8@example.com', 'email9@example.com' ); break; default: // These will be the recipients if the subject does not match any above $config['recipients'] = array( 'email1@example.com', 'email4@example.com', 'email7@example.com' ); break; }
- On line 1, replace
subject
with the unique field name - On lines 2, 9 and 16, replace the string after each
case
statement so that it matches thevalue
attribute of the option in the select menu HTML of the form