Send email to different email depending on taxonomy term This was fairly simple to do in D7 and is a common request. How would I send an email to a different email address depending on a taxonomy term chosen from a dropdown box on the contact form?
I don't know how you did it in D7, but hook_mail_alter is my preferred solution. And in hook_form_contact_site_form_alter i would add taxonomy term reference field to the contact form.


  This still works in D8


Code would look like this in your custom module:

/**
 * Implements hook_mail_alter().
 */
function YOUR_MODULE_mail_alter(&amp;$message) {

  if ($message['id'] == 'contact_page_mail') {

    $tid = $message['params']['your_form_field'];
    if (!empty($tid) &amp;&amp; $tid &gt; 0) {
      // $tid to determine the address ?!
      $message['to'] = 'your@emai.l';
    }
  }

}