You are here

function mimemail_example_form_validate in Mime Mail 7

Form validation logic for the email contact form.

File

modules/mimemail_example/mimemail_example.module, line 135
Core and contrib hook implementations for Mime Mail Example module.

Code

function mimemail_example_form_validate($form, &$form_state) {
  $values =& $form_state['values'];
  if (!valid_email_address($values['to'])) {
    form_set_error('to', t('That e-mail address is not valid.'));
  }
  $file = file_save_upload('attachment');
  if ($file) {
    $file = file_move($file, 'public://');
    $values['params']['attachments'][] = array(
      'filepath' => $file->uri,
    );
  }
}