Contact Form Plugin how to send to different recipients based on country selected? I'm trying to build a plugin that fires on the Contact Form Plugins contactForm.beforeSendwhat the plugin needs to do is add a recipient email if certain countries are selected. So far I have created the below which checks for the countries and checks against an array to see if they are in it. This works, so far so good. What I need to do now is somehow add to the contact form plugins $toEmails variable if a country is in the array but I'm not sure how to do this from within the event listener. Is this even possible?

public function init() {
    craft()-&gt;on('contactForm.beforeSend', function(ContactFormEvent $event) {
        $message = $event-&gt;params['message'];
        $ukArray = array('United Kingdom','Wales','Scotland','Ireland');
        $country = '';
        foreach ($message as $key =&gt; $field) {
            if($key == 'messageFields') {
                $country = $field['Country'];
            }
        }
        if (in_array($country, $ukArray)) {
            // add an email address to the contact form $toEmails array
        } 
    });
}
I'm not sure this is going to be possible with the current version (1.8.1) of Contact Form.

The only thing passed into the beforeSend event is the message, so it doesn't really give you a chance to modify other properties of the email.

Maybe you could pull it off by dynamically adding these addresses with some JavaScript that checked selected countries and added to post, but those values are expected to be |hashed.

You could always just fork the plugin and modify it for your specific needs, too.