You are here

function mimemail_send_mail_action_validate in Mime Mail 6

Validate the action form.

File

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

Code

function mimemail_send_mail_action_validate($form, $form_state) {
  $to = explode(',', $form_state['values']['to']);
  $cc = explode(',', $form_state['values']['cc']);
  $bcc = explode(',', $form_state['values']['bcc']);
  foreach ($to as $recipient) {
    $recipient = trim($recipient);
    if (!valid_email_address($recipient) && $recipient != '%author') {
      form_set_error('recipient', t('Please enter a valid e-mail address or %author.', array(
        '%author' => '%author',
      )));
    }
  }
  foreach ($cc as $recipient) {
    $recipient = trim($recipient);
    if (!empty($recipient) && !valid_email_address($recipient) && $recipient != '%author') {
      form_set_error('cc', t('Please enter a valid e-mail address or %author.', array(
        '%author' => '%author',
      )));
    }
  }
  foreach ($bcc as $recipient) {
    $recipient = trim($recipient);
    if (!empty($recipient) && !valid_email_address($recipient) && $recipient != '%author') {
      form_set_error('bcc', t('Please enter a valid e-mail address or %author.', array(
        '%author' => '%author',
      )));
    }
  }
  $reply_to = trim($form_state['values']['reply_to']);
  if (!empty($reply_to) && !valid_email_address($reply_to) && $reply_to != '%author') {
    form_set_error('reply_to', t('Please enter a valid e-mail address or %author.', array(
      '%author' => '%author',
    )));
  }
}