本文整理匯總了Python中validate_email.validate_email方法的典型用法代碼示例。如果您正苦於以下問題:Python validate_email.validate_email方法的具體用法?Python validate_email.validate_email怎麽用?Python validate_email.validate_email使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類validate_email
的用法示例。
在下文中一共展示了validate_email.validate_email方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: __init__
# 需要導入模塊: import validate_email [as 別名]
# 或者: from validate_email import validate_email [as 別名]
def __init__(self, email, password, first_name=None, last_name=None,
address=None, address2=None, city=None, state=None, zip=None):
self.create_date = datetime.now()
if not email:
raise ValidationError('ACCOUNTS_MISSING_EMAIL')
elif not validate_email(email):
raise ValidationError('ACCOUNTS_BAD_EMAIL')
else:
self.email = email
if not password:
raise ValidationError('ACCOUNTS_MISSING_PASSWORD')
else:
self.password = password_hash(password)
self.api_key = random_hash("%s%s" % (email, self.password))
self.first_name = first_name
self.last_name = last_name
self.address = address
self.address2 = address2
self.city = city
self.state = state
self.zip = zip
示例2: add_email
# 需要導入模塊: import validate_email [as 別名]
# 或者: from validate_email import validate_email [as 別名]
def add_email(message):
user_lang(message)
try:
text = message.text.lower()
except AttributeError:
text = None
if text in cmds:
return 0
elif '/' not in message.text:
if validate_email(message.text.lower()):
upd_user_email(db, table, message.from_user.id, '"' +
str(message.text) + '"')
data = select_user(db, table, message.from_user.id, '*')
if '@' not in str(data[3]):
msg = bot.reply_to(message, i18n.t('bot.askemail'))
bot.register_next_step_handler(msg, add_email)
return 0
if '@' not in str(data[2]):
msg = bot.reply_to(message, i18n.t('bot.askemail2'))
bot.register_next_step_handler(msg, add_email)
return 0
msg = bot.reply_to(message,
str(u'\U00002705') + i18n.t('bot.success'),
parse_mode='HTML', reply_markup=button)
else:
msg = bot.send_message(message.from_user.id, str(u'\U000026A0')
+ i18n.t('bot.askemail'), parse_mode='HTML')
bot.register_next_step_handler(msg, add_email)
else:
msg = bot.send_message(message.from_user.id,
i18n.t('bot.askemail'), parse_mode='HTML')
bot.register_next_step_handler(msg, add_email)
示例3: search
# 需要導入模塊: import validate_email [as 別名]
# 或者: from validate_email import validate_email [as 別名]
def search():
inputfil = raw_input("Type the path of file containing a list of emails: ")
with open(inputfil) as inputfile:
for line in inputfile:
results.append(line.strip())
count = 0
for i in results:
is_valid = validate_email(i,verify=True)
count += 1
if str(is_valid).upper() == "TRUE":
stdout.write(GREEN + "[*] FOUND - [" + i + "] "+ BLUE + "{line " + str(count) + "}\n" + END)
else:
stdout.write(RED + "[!] NOTFD - [" + i + "]" + BLUE + " {line " + str(count) + "}\n" + END)
示例4: single
# 需要導入模塊: import validate_email [as 別名]
# 或者: from validate_email import validate_email [as 別名]
def single():
ema = raw_input("Type the email to search: ")
is_valid = validate_email(ema,verify=True)
if str(is_valid).upper() == "TRUE":
stdout.write(GREEN + "[*] FOUND - [" + ema + "]\n" + END)
else:
stdout.write(RED + "[!] NOTFD - [" + ema + "]\n" + END)
示例5: email_validator
# 需要導入模塊: import validate_email [as 別名]
# 或者: from validate_email import validate_email [as 別名]
def email_validator(value, **kwargs):
if not validate_email.validate_email(value):
raise ValidationError(MESSAGES['format']['invalid_email'].format(value))
示例6: _email_or_md5
# 需要導入模塊: import validate_email [as 別名]
# 或者: from validate_email import validate_email [as 別名]
def _email_or_md5(s):
if validate_email(s) or re.match(r"^[0-9A-Fa-f]{32}$", s):
return s
raise ValueError
# based off of:
# http://stackoverflow.com/questions/2532053/validate-a-hostname-string
示例7: check_valid_email
# 需要導入模塊: import validate_email [as 別名]
# 或者: from validate_email import validate_email [as 別名]
def check_valid_email(func):
@six.wraps(func)
def decorator(request, email, *args, **kwargs):
if not validate_email.validate_email(email):
raise stethoscope.exceptions.ValidationError("email address", email)
return func(request, email, *args, **kwargs)
return decorator
示例8: main
# 需要導入模塊: import validate_email [as 別名]
# 或者: from validate_email import validate_email [as 別名]
def main():
#Imprimimos el banner
print(config.banner)
nick = input("Insert nick:")
#Buscamos en Facebook
facebook.get_postsFB(nick)
#Buscamos emails
for email in emails:
target = nick + email
try:
is_valid = validate_email(target, check_regex=True, check_mx=True, smtp_timeout=10, dns_timeout=10, use_blacklist=True)
if is_valid:
print("|----[INFO][EMAIL][>] " + target)
print("|--------[INFO][EMAIL][>] Email validated...")
else:
print("|----[INFO][TARGET][>] " + target)
print("|--------[INFO][EMAIL][>] It's not created...")
except Exception as e:
print(e)
print("[INFO][TARGET][>] " + target)
print("|--[INFO][EMAIL] No verification possible... ")
#Buscamos en las plataformas
print("This process may take a few minutes...")
r_nicks = getnickWebs(nick)
for n in r_nicks:
print("|----[INFO][" + n.upper() + "][>] " + r_nicks.get(n).replace("data", nick))
print("|")
print("|----[INFO][START] Scanning emails with nicks...")
print("|")
示例9: send_login_email
# 需要導入模塊: import validate_email [as 別名]
# 或者: from validate_email import validate_email [as 別名]
def send_login_email(request_source_url, email):
if not validate_email(email):
raise LoginEmailException('Please provide a valid email address')
email_login_link_object = models.EmailLoginLink(email=email,
secret=utils.generate_secret(32))
email_login_link_object.put()
html_template = JINJA_ENVIRONMENT.get_template('auth/login_link_email.html')
txt_template = JINJA_ENVIRONMENT.get_template('auth/login_link_email.txt')
if '/play_queued_request' in request_source_url:
emailed_url = request_source_url
else:
scheme, remainder = request_source_url.split('://')
emailed_url = '%s://%s/_/auth/email_callback' % (scheme, remainder.split('/')[0])
login_url = '%s?%s' % (emailed_url,
urllib.urlencode({'e': email, 's': email_login_link_object.secret}))
html = html_template.render({'login_url': login_url})
text = txt_template.render({'login_url': login_url})
email_data = {'recipient_email': email,
'subject': 'Log in to Trotto',
'plaintext': text,
'html': html}
deferred.defer(email_helper.send_email,
email_data)
示例10: filterEmails
# 需要導入模塊: import validate_email [as 別名]
# 或者: from validate_email import validate_email [as 別名]
def filterEmails(email):
"""Filter email address
"""
try:
if validate_email.validate_email(email, check_mx=False):
return "", email
return email, ""
except:
return email, ""
示例11: create_record
# 需要導入模塊: import validate_email [as 別名]
# 或者: from validate_email import validate_email [as 別名]
def create_record():
"""Create a book request record
@param email: post : the requesters email address
@param title: post : the title of the book requested
@return: 201: a new_uuid as a flask/response object \
with application/json mimetype.
@raise 400: misunderstood request
"""
if not request.get_json():
abort(400)
data = request.get_json(force=True)
if not data.get('email'):
abort(400)
if not validate_email(data['email']):
abort(400)
if not data.get('title'):
abort(400)
new_uuid = str(uuid.uuid4())
book_request = {
'title': data['title'],
'email': data['email'],
'timestamp': datetime.now().timestamp()
}
BOOK_REQUESTS[new_uuid] = book_request
# HTTP 201 Created
return jsonify({"id": new_uuid}), 201
示例12: edit_record
# 需要導入模塊: import validate_email [as 別名]
# 或者: from validate_email import validate_email [as 別名]
def edit_record(_id):
"""Edit a book request record
@param email: post : the requesters email address
@param title: post : the title of the book requested
@return: 200: a booke_request as a flask/response object \
with application/json mimetype.
@raise 400: misunderstood request
"""
if _id not in BOOK_REQUESTS:
abort(404)
if not request.get_json():
abort(400)
data = request.get_json(force=True)
if not data.get('email'):
abort(400)
if not validate_email(data['email']):
abort(400)
if not data.get('title'):
abort(400)
book_request = {
'title': data['title'],
'email': data['email'],
'timestamp': datetime.now().timestamp()
}
BOOK_REQUESTS[_id] = book_request
return jsonify(BOOK_REQUESTS[_id]), 200
示例13: validate
# 需要導入模塊: import validate_email [as 別名]
# 或者: from validate_email import validate_email [as 別名]
def validate(self):
if not self.email:
raise ValidationError('ACCOUNTS_MISSING_EMAIL')
if not validate_email(self.email):
raise ValidationError('ACCOUNTS_BAD_EMAIL')
if self.first_name and len(self.first_name) > 255:
raise ValidationError('ACCOUNTS_BAD_FIRST_NAME')
if self.last_name and len(self.last_name) > 255:
raise ValidationError('ACCOUNTS_BAD_LAST_NAME')
if self.address and len(self.address) > 255:
raise ValidationError('ACCOUNTS_BAD_ADDRESS')
if self.address2 and len(self.address2) > 255:
raise ValidationError('ACCOUNTS_BAD_ADDRESS2')
if self.city and len(self.city) > 255:
raise ValidationError('ACCOUNTS_BAD_CITY')
if self.state and len(self.state) > 64:
raise ValidationError('ACCOUNTS_BAD_STATE')
if self.zip and len(self.zip) > 24:
raise ValidationError('ACCOUNTS_BAD_ZIP')
if self.email_success and self.email_success != 0 and \
self.email_success != 1:
raise ValidationError('ACCOUNTS_BAD_REQUEST')
if self.email_fail and self.email_fail != 0 and self.email_fail != 1:
raise ValidationError('ACCOUNTS_BAD_REQUEST')
if self.email_list and self.email_list != 0 and self.email_list != 1:
raise ValidationError('ACCOUNTS_BAD_REQUEST')
return True
示例14: author_email_pairs
# 需要導入模塊: import validate_email [as 別名]
# 或者: from validate_email import validate_email [as 別名]
def author_email_pairs(self):
unknown_author_response = [{"name": "UNKNOWN", "email": None}]
clean_byline = self._clean_byline()
if not clean_byline:
return unknown_author_response
responses = []
for author_clause in clean_byline.split(","):
author_name = None
author_email = None
clause_replace_patterns = [
"\(.*?\)", # here so can get before comma split
"\[.*?\]",
"\[.*?$"
]
for pattern in clause_replace_patterns:
author_clause = re.sub(pattern, "", author_clause, re.IGNORECASE)
if not author_clause or (len(author_clause) < 6):
pass
if "<" in author_clause:
(author_name, author_email) = author_clause.split("<", 1)
author_email = re.sub("(>.*)", "", author_email)
if not validate_email(author_email):
author_email = None
else:
author_name = author_clause
if author_name:
author_name = author_name.strip("\t .'(")
author_name = author_name.strip('"')
if author_name or author_email:
responses.append({"name":author_name, "email":author_email})
if not responses:
responses = unknown_author_response
return responses
示例15: message_factory
# 需要導入模塊: import validate_email [as 別名]
# 或者: from validate_email import validate_email [as 別名]
def message_factory(**kwargs):
request = get_current_request()
application_settings = request.registry.application_settings
settings = request.runtime_settings
# EmailMessage builder
message = EmailMessage(application_settings.smtp, settings.vendor.email)
if 'reply' in settings.vendor.email.addressbook:
message.add_reply(read_list(settings.vendor.email.addressbook.reply))
is_support_email = False
if 'recipients' in kwargs:
for recipient in kwargs['recipients']:
if recipient == 'support':
is_support_email = True
if recipient in settings.vendor.email.addressbook:
message.add_recipient(read_list(settings.vendor.email.addressbook[recipient]))
else:
log.warning('Could not add recipient {}'.format(recipient))
# Extend "To" and "Reply-To" addresses by email address of user
#request.user.username = 'test@example.org'; request.user.fullname = 'Hello World' # debugging
if request.user.username:
username = request.user.username
if validate_email(username):
if request.user.fullname:
pair = (request.user.fullname, username)
else:
pair = (None, username)
try:
user_email = formataddr(pair)
except Exception as ex:
log.warning('Computing "user_email" failed: Could not decode email address from "{}": {}'.format(username, ex))
return message
# Add user email as "Reply-To" address
message.add_reply(user_email)
# If it's a support email, also add user herself as a recipient
if is_support_email:
message.add_recipient(user_email)
else:
log.warning('Computing "user_email" failed: Email address "{}" is invalid'.format(username))
return message