The best way would be to hook into the ‘fm_form_submission’ action. This is something I added recently. You can use the template here so that updates to form manager don’t overwrite your changes. Just modify the code and upload it as a new plugin.
So here are the details:
1) Give the list item a nickname, ’email-list’. For now I’ll assume the list has the items ‘Sales’, ‘General’, ‘Refunds’.
2) Inside the fm_custom_submission_action function, put the following:
global $fm_display;
$formInfo = $args['form'];
$postData = $args['data'];
$subject = fm_getSubmissionDataShortcoded($formInfo['email_subject'], $formInfo, $postData);
$message = $fm_display->displayDataSummary('email', $formInfo, $postData);
$headers = 'From: '.fm_getSubmissionDataShortcoded($formInfo['email_from'], $formInfo, $postData)."\r\n".
'Reply-To: '.fm_getSubmissionDataShortcoded($formInfo['email_from'], $formInfo, $postData)."\r\n".
'MIME-Version: 1.0'."\r\n".
'Content-type: text/html'."\r\n";
This code will load the e-mail settings for the current form, basically just the ‘Subject’ and ‘From’ fields as you have them set in the form editor. You could replace these with whatever you want, but make sure to keep the MIME-Version and Content-type parts in the $headers variable or else you won’t be able to have HTML in the message body.
3) Add the following to the end of the same function:
$addressArray = array(
'Sales' => "[email protected]",
'General' => "[email protected]",
'Refunds' => "[email protected]",
);
fm_sendEmail($addressArray[$postData['email-list']], $subject, $message, $headers);
This is the key part, where you specify an e-mail address to send to based on the value of the ’email-list’ item. Make sure to put a comma after each item in the $addressArray variable like in the example.
Good luck!