Unify detecting free domain in JS and PHP from one source
[MAILPOET-1882]
This commit is contained in:
@@ -3,58 +3,9 @@ import PropTypes from 'prop-types';
|
||||
import MailPoet from 'mailpoet';
|
||||
import ReactStringReplace from 'react-string-replace';
|
||||
|
||||
/* https://github.com/mailcheck/mailcheck/wiki/List-of-Popular-Domains */
|
||||
const badDomains = [
|
||||
/* Default domains included */
|
||||
'aol.com', 'att.net', 'comcast.net', 'facebook.com', 'gmail.com', 'gmx.com', 'googlemail.com',
|
||||
'google.com', 'hotmail.com', 'hotmail.co.uk', 'mac.com', 'me.com', 'mail.com', 'msn.com',
|
||||
'live.com', 'sbcglobal.net', 'verizon.net', 'yahoo.com', 'yahoo.co.uk',
|
||||
|
||||
/* Other global domains */
|
||||
'email.com', 'fastmail.fm', 'games.com' /* AOL */, 'gmx.net', 'hush.com', 'hushmail.com', 'icloud.com',
|
||||
'iname.com', 'inbox.com', 'lavabit.com', 'love.com' /* AOL */, 'outlook.com', 'pobox.com', 'protonmail.com',
|
||||
'rocketmail.com' /* Yahoo */, 'safe-mail.net', 'wow.com' /* AOL */, 'ygm.com' /* AOL */,
|
||||
'ymail.com' /* Yahoo */, 'zoho.com', 'yandex.com',
|
||||
|
||||
/* United States ISP domains */
|
||||
'bellsouth.net', 'charter.net', 'cox.net', 'earthlink.net', 'juno.com',
|
||||
|
||||
/* British ISP domains */
|
||||
'btinternet.com', 'virginmedia.com', 'blueyonder.co.uk', 'freeserve.co.uk', 'live.co.uk',
|
||||
'ntlworld.com', 'o2.co.uk', 'orange.net', 'sky.com', 'talktalk.co.uk', 'tiscali.co.uk',
|
||||
'virgin.net', 'wanadoo.co.uk', 'bt.com',
|
||||
|
||||
/* Domains used in Asia */
|
||||
'sina.com', 'sina.cn', 'qq.com', 'naver.com', 'hanmail.net', 'daum.net', 'nate.com', 'yahoo.co.jp', 'yahoo.co.kr', 'yahoo.co.id', 'yahoo.co.in', 'yahoo.com.sg', 'yahoo.com.ph', '163.com', '126.com', 'aliyun.com', 'foxmail.com',
|
||||
|
||||
/* French ISP domains */
|
||||
'hotmail.fr', 'live.fr', 'laposte.net', 'yahoo.fr', 'wanadoo.fr', 'orange.fr', 'gmx.fr', 'sfr.fr', 'neuf.fr', 'free.fr',
|
||||
|
||||
/* German ISP domains */
|
||||
'gmx.de', 'hotmail.de', 'live.de', 'online.de', 't-online.de' /* T-Mobile */, 'web.de', 'yahoo.de',
|
||||
|
||||
/* Italian ISP domains */
|
||||
'libero.it', 'virgilio.it', 'hotmail.it', 'aol.it', 'tiscali.it', 'alice.it', 'live.it', 'yahoo.it', 'email.it', 'tin.it', 'poste.it', 'teletu.it',
|
||||
|
||||
/* Russian ISP domains */
|
||||
'mail.ru', 'rambler.ru', 'yandex.ru', 'ya.ru', 'list.ru',
|
||||
|
||||
/* Belgian ISP domains */
|
||||
'hotmail.be', 'live.be', 'skynet.be', 'voo.be', 'tvcablenet.be', 'telenet.be',
|
||||
|
||||
/* Argentinian ISP domains */
|
||||
'hotmail.com.ar', 'live.com.ar', 'yahoo.com.ar', 'fibertel.com.ar', 'speedy.com.ar', 'arnet.com.ar',
|
||||
|
||||
/* Domains used in Mexico */
|
||||
'yahoo.com.mx', 'live.com.mx', 'hotmail.es', 'hotmail.com.mx', 'prodigy.net.mx',
|
||||
|
||||
/* Domains used in Brazil */
|
||||
'yahoo.com.br', 'hotmail.com.br', 'outlook.com.br', 'uol.com.br', 'bol.com.br', 'terra.com.br', 'ig.com.br', 'itelefonica.com.br', 'r7.com', 'zipmail.com.br', 'globo.com', 'globomail.com', 'oi.com.br',
|
||||
];
|
||||
|
||||
const SenderEmailAddressWarning = ({ emailAddress }) => {
|
||||
const emailAddressDomain = emailAddress.split('@').pop().toLowerCase();
|
||||
if (badDomains.indexOf(emailAddressDomain) > -1) {
|
||||
if (window.mailpoet_free_domains.indexOf(emailAddressDomain) > -1) {
|
||||
const userHostDomain = window.location.hostname.replace('www.', '');
|
||||
return (
|
||||
<React.Fragment>
|
||||
|
@@ -5,6 +5,7 @@ namespace MailPoet\Twig;
|
||||
use Carbon\Carbon;
|
||||
use MailPoet\Config\ServicesChecker;
|
||||
use MailPoet\Settings\SettingsController;
|
||||
use MailPoet\Util\FreeDomains;
|
||||
use MailPoet\WP\Functions as WPFunctions;
|
||||
|
||||
if (!defined('ABSPATH')) exit;
|
||||
@@ -110,6 +111,11 @@ class Functions extends \Twig_Extension {
|
||||
array($this, 'getTwoLettersLocale'),
|
||||
array('is_safe' => array('all'))
|
||||
),
|
||||
new \Twig_SimpleFunction(
|
||||
'mailpoet_free_domains',
|
||||
array($this, 'getFreeDomains'),
|
||||
array('is_safe' => array('all'))
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
@@ -199,4 +205,8 @@ class Functions extends \Twig_Extension {
|
||||
function getTwoLettersLocale() {
|
||||
return explode('_', WPFunctions::get()->getLocale())[0];
|
||||
}
|
||||
|
||||
function getFreeDomains() {
|
||||
return FreeDomains::FREE_DOMAINS;
|
||||
}
|
||||
}
|
||||
|
@@ -53,6 +53,7 @@ jQuery('.toplevel_page_mailpoet-newsletters.menu-top-last')
|
||||
var mailpoet_analytics_data = <%= json_encode(get_analytics_data()) %>;
|
||||
var mailpoet_analytics_public_id = <%= json_encode(get_analytics_public_id()) %>;
|
||||
var mailpoet_analytics_new_public_id = <%= is_analytics_public_id_new() | json_encode %>;
|
||||
var mailpoet_free_domains = <%= json_encode(mailpoet_free_domains()) %>;
|
||||
// RFC 5322 standard; http://emailregex.com/ combined with https://google.github.io/closure-library/api/goog.format.EmailAddress.html#isValid
|
||||
var mailpoet_email_regex = /(?=^[+a-zA-Z0-9_.!#$%&'*\/=?^`{|}~-]+@([a-zA-Z0-9-]+\.)+[a-zA-Z0-9]{2,63}$)(?=^(([^<>()\[\]\\.,;:\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,})))/;
|
||||
</script>
|
||||
|
Reference in New Issue
Block a user