Skip to content

Instantly share code, notes, and snippets.

@alpharder
Created August 10, 2015 07:24
Show Gist options
  • Save alpharder/0c7225384c1c41c928e0 to your computer and use it in GitHub Desktop.
Save alpharder/0c7225384c1c41c928e0 to your computer and use it in GitHub Desktop.
diff --git a/app/Tygh/Mailer.php b/app/Tygh/Mailer.php
index 7d8bdd2..eeb4ace 100644
--- a/app/Tygh/Mailer.php
+++ b/app/Tygh/Mailer.php
@@ -261,4 +261,9 @@ class Mailer extends \PHPMailer
return array_unique($result);
}
+
+ public static function ValidateAddress($email, $method = 'auto')
+ {
+ return fn_validate_email($email, false);
+ }
}
diff --git a/app/functions/fn.common.php b/app/functions/fn.common.php
index 733c01d..edee6ee 100644
--- a/app/functions/fn.common.php
+++ b/app/functions/fn.common.php
@@ -1286,9 +1286,9 @@ function fn_debug($debug_data = array())
*/
function fn_validate_email($email, $show_error = false)
{
- $email_regular_expression = "^(([^<>()[\]\\.,;:\s@\"]+(\.[^<>()[\]\\.,;:\s@\"]+)*)|(\".+\"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$";
+ $regex = '/^(.*<?)(.*)@(.*?)(>?)$/';
- if (preg_match("/" . $email_regular_expression . "/i", stripslashes($email))) {
+ if (strlen($email) < 320 && preg_match($regex, stripslashes($email))) {
return true;
} elseif ($show_error) {
fn_set_notification('E', __('error'), __('text_not_valid_email', array(
diff --git a/js/tygh/core.js b/js/tygh/core.js
index 64fa6b2..eee8d4b 100644
--- a/js/tygh/core.js
+++ b/js/tygh/core.js
@@ -109,8 +109,7 @@ var Tygh = {
is: {
email: function(email)
{
- var regex = new RegExp('^(([^<>()[\\]\\\\.,;:\\s@\\"]+(\\.[^<>()[\\]\\\\.,;:\\s@\\"]+)*)|(\\".+\\"))@((\\[[0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}\\])|(([a-zA-Z\\-0-9]+\\.)+[a-zA-Z]{2,}))$');
- return regex.test(email);
+ return /\S+@\S+.\S+/i.test(email) ? true : false;
},
blank: function(val)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment