嗨,我正在寻找一种方法来使用提供的电子邮件地址验证域 域名可以是 http://www.test.free.com http://www.free.com.au http://www.free .com.au.org http://www.free.com.org 或者可以有一个带有任意数量的子子域和任意数量的验证的域名。
验证电子邮件应该包含域,这是我到目前为止写的
if domain_url is not None and verification_email is not None:
logging.info('==============================')
logging.info('BOTH WERE NOT NONE')
logging.info('==============================')
domain_email = verification_email.split('@')[1].split('.')[0]
logging.info('==============================')
logging.info(domain_email)
logging.info('==============================')
verify_domain_url_list = domain_url.split('.')
if len(verify_domain_url_list) == 4:
verify_domain_url_list.pop()
verify_domain_url_list.pop()
if len(verify_domain_url_list) == 3:
verify_domain_url_list.pop()
verify_status = domain_email in verify_domain_url_list
if verify_status:
return 'yes'
else:
pre_domain_address = verify_domain_url_list[0].split('//')[1]
if pre_domain_address is not None and \
domain_email in pre_domain_address:
return 'yes'
else:
return 'no'
return 'no'
但这并不适合所有可能性。有人可以帮忙吗?