getting key of submitted entity list field I'm having troubles with the following:
I created a form with entityforms and now i want to send a confirmation email with mimemail.
Getting that to work is no problem.

But i need to perform a small check with the php evaluation function of mimemail.

The form is for customers to place an order, but they have to specify 1 of 2 printing techniques available, 'fdm' or 'polyjet'. This is a 'list' field in the entityform with the two options.
And in the confirmation email i need to check what technique has been chosen so i can display some lines of text depending on the technique.

For my php evaluation i would like to get the key (machine readable name) of the submitted value.

So i can do something like this:

switch ($chosenkey){
    case "pol":
        echo "lines of text for polyjet";
        break;
    case "fdm":
        echo "lines of text for fdm";
        break;
    default:
        echo "error";
}


So basically i just need to know how i can create a variable ($chosenkey) that contains the submitted key of the chosen printing technique.

anyone any idea how i can accomplish this? I have googled around but can't find any relevant answer.
I'm not familiar with entityform so forgive me if none of this makes sense, but I imagine it works much like webform in that it sends the e-mail to the addresses you set up upon a successful form submit with no need for any custom code. So adding another validator or submit function to send the e-mail would result in two e-mails.

What you can do is use hook_mail_alter in a custom module and see what variables entityform passes to its drupal_mail call. With any luck, all the form values from $form_state will be included and you can do the check there and then change the $message['body'] array accordingly.

In the hook_mail_alter you can do a switch statement for the $message['key'] or $message['id'] to make sure you're not running your check for every mail your drupal site sends but only for the entityform in question.

I would also include a custom token of sorts in the template you, presumably, entered when settings up the entityform so you can easily change the e-mail body once you've run the check. I don't know if you could do it with Drupal's Token system, but even just entering 'my_module_custom_token' in the template and then using str_replace on 'my_module_custom_token' with the correct sentence in the mail_alter is better than nothing.

If none of this applies, then naturally disregard this answer entirely.