From 39ab70f9ada910f5c33c120c9714be3a441ea995 Mon Sep 17 00:00:00 2001 From: topilski Date: Sun, 4 Feb 2018 10:34:58 +0300 Subject: [PATCH] Role emails --- base/utils.py | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/base/utils.py b/base/utils.py index 21d70ab..1bac78e 100644 --- a/base/utils.py +++ b/base/utils.py @@ -40,6 +40,20 @@ def is_valid_email(email: str) -> bool: return True +def is_role_based_email(email: str) -> bool: + r = re.compile('([^@]+)@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,4})$') + match = r.match(email) + if not match: + return False + + start = match.group(1) + for x in ['noreply', 'support', 'admin']: + if start == x: + return True + + return False + + def read_file_line_by_line_to_list(file) -> list: if not os.path.exists(file): raise BuildError('file path: {0} not exists'.format(file))