You are here

function mailhandler_form_validate in Mailhandler 5

Verify that the Mailbox is valid, and save it to the database.

File

./mailhandler.module, line 785

Code

function mailhandler_form_validate($form_id, $edit) {
  if ($error = user_validate_mail($edit['mail'])) {
    form_set_error('mail', $error);
  }
  if ($edit['mailto'] && ($error = user_validate_mail($edit['mailto']))) {
    form_set_error('mailto', $error);
  }
  if ($edit['domain'] && $edit['port'] && !is_numeric($edit['port'])) {

    // assume external mailbox
    form_set_error('port', t('Mailbox port must be an integer.'));
  }
  if (!$edit['domain'] && !$edit['port'] && $edit['folder']) {

    // assume local folder
    // check read and write permission
    if (!is_readable($edit['folder']) || !is_writable($edit['folder'])) {
      form_set_error('port', t('The local folder has to be readable and writable by owner of the webserver process, e.g. nobody.'));
    }
  }
}