Help please! I am trying to verify emails by sending requests to SMTP servers. The weirdest thing is when I test on Linux, it may work for more emails. When I test in Windows, I did some analysis and like for 79% of emails will show the WinError10060 problem.
I tried using VPN (changing the IP), proxies as well (as suggested in previous questions here for this WinError10060) but they didn't seem to work for me.
I have been dealing with this for a couple of weeks and I really need serious help for this!
Previous posted question for this error only said for proxies and I tried but I don't know what's wrong or am I using them right or not (how to know?). I even turned off the firewall on my pc (since in some online sources they explained that the firewall may block the SMTP port), still the same error:
[WinError 10060] A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond
Could this be from the firewall in the router or the internet provider blocking the port? But in the mean time, for 21% of emails I'll get answers like 250, 550 etc.
Here's the code:
for email in rows: email = email[0] start = time.time() if(email[-3:] == 'png' or email[-3:] == 'jpg'): pass else: # email_result = " " # code_result = " " counter += 1 # email = email.strip() # email = email.rstrip(',') print("\n\n\n") maildomain = email.split("@")[-1] print("maildomain: ", maildomain) nstoken = "mail exchanger = " mailserver = "" mailservers = [] print("Checking MX Server") # Checking for domain names # Command: nslookup -type=mx [mx server here] plines = os.popen("nslookup -type=mx " + maildomain).readlines() for pline in plines: if nstoken in pline: mailserver = pline.split(nstoken)[1].strip() # No need this line in Windows environment mailserver = mailserver.split(" ")[-1] mailservers.append(mailserver) print("Checking e-mail address: ", email) invalid_emails = [550, 551, 553] cannot_verify_emails = [450, 451, 452] print("\nmailservers: ", mailservers) if mailservers == []: email_result = "Invalid" code_result = 000 print("No mail servers found") else: i = mailservers[0] print("i: ", mailservers[0]) try: # timeout = 10 # socket.setdefaulttimeout(timeout) s = smtplib.SMTP(i) # Identifying to an ESMTP server # Command helo hi / ehlo hi rep1 = s.ehlo() print("rep1: ", rep1) if rep1[0] == 250: rep2 = s.mail("grencir1982@teleworm.us") print("rep2: ", rep2) if rep2[0] == 250: rep3 = s.rcpt(email) print("rep3: ", rep3) if rep3[0] == 250: print(email, " is valid, " + str(rep3[0])) email_result = "Valid" elif rep3[0] in cannot_verify_emails: print(email, " verification not allowed" + str(rep3[0])) email_result = "Server disallows verification or user mailbox is currently unavailable" elif rep3[0] in invalid_emails: print(email, " doesn't exist " + str(rep3[0])) email_result = "Invalid" else: print(email, " response, " + str(rep3[0])) email_result = "Other response" code_result = str(rep3[0]) else: print("rep2: s.rcpt not working") email_result = "Other response" # code_result = str(rep2[0]) else: print("rep1: s.mail not working") email_result = "Other response: Probably IP Blacklisted" # code_result = str(rep1[0]) s.quit() except socket.timeout: email_result = "Socket Timeout Exception" code_result = 000 # continue print("Socket Timeout") pass except smtplib.SMTPServerDisconnected as e: print(e) except smtplib.SMTPSenderRefused as e: print(e) except smtplib.SMTPRecipientsRefused as e: print(e) except smtplib.SMTPDataError as e: print(e) except smtplib.SMTPHeloError as e: print(e) except smtplib.SMTPAuthenticationError as e: print(e) except smtplib.SMTPResponseException as e: print(e) # except SMTPException as e: # email_result = "SMTP Exception" # code_result = 000 # print(e) except Exception as e: # timeout = 10 # socket.setdefaulttimeout(timeout) # print(email, " general exception") email_result = str(e) code_result = 000 print(e) self.emails_res.append(email) self.statuses.append(email_result) self.mx_records.append(mailserver) self.response_codes.append(code_result)