source: mailjam/postman/tools.py@ 11:078c7b030cee

Last change on this file since 11:078c7b030cee was 11:078c7b030cee, checked in by Borja Lopez <borja@…>, 12 years ago

Removed legacy configs from the config module

Added some headers to the sources (setting author, email, website
and references to the LICENSE)

File size: 993 bytes
Line 
1# -*- coding: utf-8 -*-
2
3"""
4The postman project - tools.py
5
6This file is released under the BSD license, see LICENSE for
7more information.
8
9Francisco de Borja Lopez Rio - <borja@codigo23.net>
10Soluciones Informaticas Codigo23 S.L.U. - http://codigo23.net
11"""
12
13import re
14
15def validate_email_address(address):
16
17 """
18 This function validates a given address, returning True
19 if it is a valid address, False otherwise.
20
21 The function uses a regexp from the django project, and
22 it is inspired in this snippet:
23
24 http://djangosnippets.org/snippets/1093/
25 """
26
27 if not isinstance(address, str):
28 return False
29
30 email_re = re.compile(
31 r"(^[-!#$%&'*+/=?^_`{}|~0-9A-Z]+(\.[-!#$%&'*+/=?^_`{}|~0-9A-Z]+)*" # dot-atom
32 r'|^"([\001-\010\013\014\016-\037!#-\[\]-\177]|\\[\001-011\013\014\016-\177])*"' # quoted-string
33 r')@(?:[A-Z0-9](?:[A-Z0-9-]{0,61}[A-Z0-9])?\.)+[A-Z]{2,6}\.?$', re.IGNORECASE) # domain
34 return True if email_re.match(address) else False
Note: See TracBrowser for help on using the repository browser.