what else can done to reach every domain -
@app.route('/<string:email>',methods=['GET','POST'])
-
def post(email):
-
blocked_keywords = ["spamhaus",
-
"proofpoint",
-
"cloudmark",
-
"banned",
-
"blacklisted",
-
"blocked",
-
"block list",
-
"denied"]
-
-
-
-
proxy = {
-
'socks4': socks.SOCKS4,
-
'socks5': socks.SOCKS5,
-
'http': socks.HTTP # does not guareentee it will work with HTTP
-
}
-
-
class UnknownProxyError(Exception):
-
def __init__(self, proxy_type):
-
self.msg = f"The proxy type {proxy_type} is not known\n Try one of socks4, socks5 or http"
-
-
class EmailFormatError(Exception):
-
-
def __init__(self, msg):
-
self.msg = msg
-
-
class SMTPRecepientException(Exception): # don't cover
-
-
def __init__(self, code, response):
-
self.code = code
-
self.response = response
-
-
-
####
-
# SMTP RCPT error handlers
-
####
-
def handle_550(response):
-
if any([keyword.encode() in response for keyword in blocked_keywords]):
-
return dict(message="Blocked by mail server- couldn't verify", deliverable=False, host_exists=True)
-
else:
-
return dict(deliverable=False, host_exists=True)
-
-
-
-
-
handle_error = {
-
# 250 and 251 are not errors
-
550: handle_550,
-
551: lambda _: dict(deliverable=False, host_exists=True),
-
552: lambda _: dict(deliverable=True, host_exists=True, full_inbox=True),
-
553: lambda _: dict(deliverable=False, host_exists=True),
-
450: lambda _: dict(deliverable=False, host_exists=True),
-
451: lambda _: dict(deliverable=False, message="Local error processing, try again later."),
-
452: lambda _: dict(deliverable=True, full_inbox=True),
-
# Syntax errors
-
# 500 (command not recognised)
-
# 501 (parameter/argument not recognised)
-
# 503 (bad command sequence)
-
521: lambda _: dict(deliverable=False, host_exists=False),
-
421: lambda _: dict(deliverable=False, host_exists=True, message="Service not available, try again later."),
-
441: lambda _: dict(deliverable=True, full_inbox=True, host_exists=True)
-
}
-
-
handle_unrecognised = lambda a: dict(message=f"Unrecognised error: {a}", deliverable=False)
-
-
-
# create a namedtuple to hold the email address
-
Address = namedtuple("Address", ["name", "addr", "username", "domain"])
-
-
class e_verifier:
-
-
def __init__(self,
-
source_addr,
-
proxy_type = None,
-
proxy_addr = None,
-
proxy_port = None,
-
proxy_username = None ,
-
proxy_password = None):
-
-
-
if proxy_type:
-
try:
-
self.proxy_type = proxy[proxy_type.lower()]
-
except KeyError as e:
-
raise UnknownProxyError(proxy_type)
-
else:
-
self.proxy_type = None
-
self.source_addr = source_addr
-
self.proxy_addr = proxy_addr
-
self.proxy_port = proxy_port
-
self.proxy_username = proxy_username
-
self.proxy_password = proxy_password
-
-
def _parse_address(self, email) -> Address:
-
-
name, addr = parseaddr(email)
-
if not addr:
-
raise EmailFormatError(f"email does not contain address: {email}")
-
try:
-
domain = addr.split('@')[-1]
-
username = addr.split('@')[:-1][0]
-
except IndexError:
-
raise EmailFormatError(f"address provided is invalid: {email}")
-
return Address(name, addr, username, domain)
-
-
def _random_email(self, domain):
-
-
return f'{binascii.hexlify(os.urandom(20)).decode()}@{domain}'
-
-
def _can_deliver(self,
-
exchange : str,
-
address : str):
-
-
host_exists = False
-
with SMTP(exchange[1],
-
proxy_type=self.proxy_type,
-
proxy_addr=self.proxy_addr,
-
proxy_port=self.proxy_port,
-
proxy_username=self.proxy_username,
-
proxy_password=self.proxy_password) as smtp:
-
host_exists = True
-
smtp.helo()
-
smtp.mail(self.source_addr)
-
test_resp = smtp.rcpt(address.addr)
-
catch_all_resp = smtp.rcpt(self._random_email(address.domain))
-
if test_resp[0] == 250:
-
deliverable = True
-
if catch_all_resp[0] == 250:
-
catch_all = True
-
else:
-
catch_all = False
-
elif test_resp[0] >= 400:
-
raise SMTPRecepientException(*test_resp)
-
return host_exists, deliverable, catch_all
-
-
def verify(self, email):
-
-
lookup = {
-
'address': None,
-
'valid_format': False,
-
'deliverable': False,
-
'full_inbox': False,
-
'host_exists': False,
-
'catch_all': False,
-
}
-
try:
-
lookup['address'] = self._parse_address(email)
-
lookup['valid_format'] = True
-
except EmailFormatError:
-
lookup['address'] = f"{email}"
-
return lookup
-
-
# look for mx record and create a list of mail exchanges
-
try:
-
mx_record = resolver.query(lookup['address'].domain, 'MX')
-
mail_exchangers = [exchange.to_text().split() for exchange in mx_record]
-
lookup['host_exists'] = True
-
except (resolver.NoAnswer, resolver.NXDOMAIN, resolver.NoNameservers):
-
lookup['host_exists'] = False
-
return lookup
-
-
for exchange in mail_exchangers:
-
try:
-
host_exists, deliverable, catch_all = self._can_deliver(exchange, lookup['address'])
-
if deliverable:
-
lookup['host_exists'] = host_exists
-
lookup['deliverable'] = deliverable
-
lookup['catch_all'] = catch_all
-
break
-
except SMTPRecepientException as err:
-
# Error handlers return a dict that is then merged with 'lookup'
-
kwargs = handle_error.get(err.code, handle_unrecognised)(err.response)
-
# This expression merges the lookup dict with kwargs
-
lookup = {**lookup, **kwargs}
-
-
except smtplib.SMTPServerDisconnected as err:
-
lookup['message'] = "Internal Error"
-
except smtplib.SMTPConnectError as err:
-
-
lookup['message'] = "Internal Error. Maybe blacklisted"
-
-
return lookup
-
-
v = e_verifier(source_addr='user@example.com')
-
email = email
-
l = v.verify(email)
-
return l
-
-
if __name__ == "__main__":
-
app.run(debug=True)
-
-
0 4135 Sign in to post your reply or Sign up for a free account.
Similar topics |
by: dmiller23462 |
last post by:
So here's my problem.....I need to set up different email
distributions based on which option in the following Select form has
been chosen....For instance if "Putaway" is chosen it needs to email
User1@here.whatever and User4@here.whatever but if "Loaded" is chosen
it needs to email User2@here.whatever and User3@here.whatever, etc,
etc...
...
|
by: email verification |
last post by:
Is there a code snippet to check if an email address is a valid account or not? When someone subscribes to our newsletter we would like to verify that it's valid and if not we can notify them
|
by: SOR |
last post by:
Although this currently defeats the spam bots in some respects - isnt it
just a mater of time before the spammers figure out a way to verify a
signup via email using rotating disposable email addresses or whatever .
And if so , Would it not be a good idea to separate the url and signup
verification code in the welcome email *now* rather than...
|
by: toedipper |
last post by:
Hello,
php and mysql
I am looking to start a newsletter on my site.
I imagine I will have a text box that users enter their email address
into and a button that says 'subscribe'
To stop people entering other peeps email address I will need some
|
by: pwilliams |
last post by:
NCOALink Change of Address Verification
Each year over 40 million Americans change their mailing addresses.
This change is equivalent to every person in California deciding to
change addresses and not tell you that they have moved. This
uncertainty results in wasted spending on undeliverable address mail,
returned mail and processing fees...
| |
by: Jagadesh |
last post by:
Hello for all,
how to create an email verification... Not an syntax
verification,. whether the email id is availble for the domain or not..
I will gave some link.. check that ...there's an code.. but its
completely functioning ... but link available as demo is functioning
good// check this link how its doing /...
Plz help me...
Thanks...
|
by: Jano |
last post by:
Hi - Happy New Year!
I have a web-site which accepted paypal payment for membership. No-one's buying so I want to make it free. The page which inputs the member details into the database needs verification, and I want to bypass the verification, but I can't figure it out. Can anyone help. - I have pasted the script below.
Many thanks, ...
|
by: shalinikonatam |
last post by:
Can any one help me?
how to verify weather the Email actually exist or not?
Thanks in Advance.
|
by: sangam56 |
last post by:
I have used cookieless mode of ASPState sql server session mode. I have used the CreateUserWizard to register user in the web site. And users must click the email verification link before being activated. This all works well. But i need to retrieve the whole session when user opens the site by clicking the email verification link. I can not use...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
| |
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in...
| |
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
| |