diff --git a/include/class.config.php b/include/class.config.php index a33f231d6bff4b7277065b8d4ca2794fe5d2f827..870f2f6dda13575706cf04c1d2cf8411e519a864 100644 --- a/include/class.config.php +++ b/include/class.config.php @@ -165,6 +165,7 @@ class OsticketConfig extends Config { 'default_help_topic' => 0, 'help_topic_sort_mode' => 'a', 'client_verify_email' => 1, + 'verify_email_addrs' => 1, ); function OsticketConfig($section=null) { @@ -615,6 +616,10 @@ class OsticketConfig extends Config { return $this->get('admin_email'); } + function verifyEmailAddrs() { + return (bool) $this->get('verify_email_addrs'); + } + function getReplySeparator() { return $this->get('reply_separator'); } @@ -1000,6 +1005,7 @@ class OsticketConfig extends Config { 'alert_email_id'=>$vars['alert_email_id'], 'default_smtp_id'=>$vars['default_smtp_id'], 'admin_email'=>$vars['admin_email'], + 'verify_email_addrs'=>isset($vars['verify_email_addrs']) ? 1 : 0, 'enable_auto_cron'=>isset($vars['enable_auto_cron'])?1:0, 'enable_mail_polling'=>isset($vars['enable_mail_polling'])?1:0, 'strip_quoted_reply'=>isset($vars['strip_quoted_reply'])?1:0, diff --git a/include/class.staff.php b/include/class.staff.php index 49df3912763e5a84825e2658ec7f843dd423868e..e937871c149e37d55d8d1d48485c218611a0d036 100644 --- a/include/class.staff.php +++ b/include/class.staff.php @@ -753,7 +753,7 @@ implements EmailContact { elseif(($uid=Staff::getIdByUsername($vars['username'])) && $uid!=$id) $errors['username']=__('Username already in use'); - if(!$vars['email'] || !Validator::is_email($vars['email'])) + if(!$vars['email'] || !Validator::is_valid_email($vars['email'])) $errors['email']=__('Valid email is required'); elseif(Email::getIdByEmail($vars['email'])) $errors['email']=__('Already in use system email'); diff --git a/include/class.validator.php b/include/class.validator.php index fcb350126a22191da7572719617d42a0cfab7be8..88075ab45b41f52c553caa2b6dd18a4b68add2fe 100644 --- a/include/class.validator.php +++ b/include/class.validator.php @@ -156,14 +156,20 @@ class Validator { return false; } - if ($verify && !checkdnsrr($m->host, 'MX')) - return false; + // According to RFC2821, the domain (A record) can be treated as an + // MX if no MX records exist for the domain. Also, include a + // full-stop trailing char so that the default domain of the server + // is not added automatically + if ($verify and !count(dns_get_record($m->host.'.', DNS_MX))) + return 0 < count(dns_get_record($m->host.'.', DNS_A|DNS_AAAA)); return true; } function is_valid_email($email) { - return self::is_email($email, false, true); + global $cfg; + // Default to FALSE for installation + return self::is_email($email, false, $cfg && $cfg->verifyEmailAddrs()); } function is_phone($phone) { diff --git a/include/i18n/en_US/help/tips/settings.email.yaml b/include/i18n/en_US/help/tips/settings.email.yaml index ddad061bf26697b757e4fea6c797b1fd0782a45a..9b257975f3f42bb91d6cf0d96d79b7f937e0498c 100644 --- a/include/i18n/en_US/help/tips/settings.email.yaml +++ b/include/i18n/en_US/help/tips/settings.email.yaml @@ -123,3 +123,11 @@ default_mta: content: > <span class="doc-desc-title">Default MTA</span> takes care of email delivery process for outgoing emails without SMTP setting. + +verify_email_addrs: + title: Verify Email Addresses + content: > + Enable this option to check if the email address has a mail + exchanger (MX) in the domain's DNS. This is useful to detect + incorrectly typed email addresses. This is perfomed in addition to + checking the email address wellformedness. diff --git a/include/staff/settings-emails.inc.php b/include/staff/settings-emails.inc.php index b10facabe98d61a05eccf10736e37b4269721c20..a20dfd6617c76bd24b7b32d03b3de8514da07f8c 100644 --- a/include/staff/settings-emails.inc.php +++ b/include/staff/settings-emails.inc.php @@ -82,6 +82,15 @@ if(!defined('OSTADMININC') || !$thisstaff || !$thisstaff->isAdmin() || !$config) <i class="help-tip icon-question-sign" href="#admins_email_address"></i> </td> </tr> + <tr> + <td width="180" class="required"><?php echo __("Verify Email Addresses");?>:</td> + <td> + <input type="checkbox" name="verify_email_addrs" <?php + if ($config['verify_email_addrs']) echo 'checked="checked"'; ?>> + <?php echo __('Verify email address domain'); ?> + <i class="help-tip icon-question-sign" href="#verify_email_addrs"></i> + </td> + </tr> <tr><th colspan=2><em><strong><?php echo __('Incoming Emails'); ?>:</strong> </em></th> <tr>