You are here

function mimemail_send_email_action_validate in Mime Mail 7

Validate the action form.

File

modules/mimemail_action/mimemail_action.module, line 150
Provide actions for Mime Mail.

Code

function mimemail_send_email_action_validate($form, $form_state) {
  $to = trim($form_state['values']['to']);
  if (!valid_email_address($to) && strpos($to, ':mail') === FALSE) {
    form_set_error('to', t('Enter a valid email address or use a token e-mail address such as %author.', array(
      '%author' => '[node:author:mail]',
    )));
  }
  $cc = explode(',', $form_state['values']['cc']);
  foreach ($cc as $recipient) {
    $recipient = trim($recipient);
    if (!empty($recipient) && !valid_email_address($recipient) && strpos($recipient, ':mail') === FALSE) {
      form_set_error('cc', t('Enter a valid email address or use a token e-mail address such as %author.', array(
        '%author' => '[node:author:mail]',
      )));
    }
  }
  $bcc = explode(',', $form_state['values']['bcc']);
  foreach ($bcc as $recipient) {
    $recipient = trim($recipient);
    if (!empty($recipient) && !valid_email_address($recipient) && strpos($recipient, ':mail') === FALSE) {
      form_set_error('bcc', t('Enter a valid email address or use a token e-mail address such as %author.', array(
        '%author' => '[node:author:mail]',
      )));
    }
  }
  $reply_to = trim($form_state['values']['reply-to']);
  if (!empty($reply_to) && !valid_email_address($reply_to) && strpos($reply_to, ':mail') === FALSE) {
    form_set_error('reply-to', t('Enter a valid email address or use a token e-mail address such as %author.', array(
      '%author' => '[node:author:mail]',
    )));
  }
}