UnixDevel Posted May 8, 2023 Report Posted May 8, 2023 AM o lista de emailuri ( gen example@example.com) si o lista destul de marisoara ( undeva la 10k) nu vreau sa imi stric repul la email def validate_email(email): try: domain = email.split('@')[1] # Check if the domain name is a public email provider if domain in ['gmail.com', 'yahoo.com', 'hotmail.com', 'aol.com']: # Open a new CSV file for writing the email addresses for this domain with open(f'{domain}.csv', 'a') as outfile: # Write the email address to the appropriate CSV file outfile.write(f'{email}\n') return f"{email} exists" else: # Resolve the MX records for the email address domain mx_records = dns.resolver.resolve(domain, 'MX') # Sort the MX records by priority mx_records = sorted(mx_records, key=lambda x: x.preference) # Loop through each MX record and try to connect to it for mx in mx_records: try: # Connect to the SMTP server smtp_conn = smtplib.SMTP(host=str(mx.exchange), port=25, timeout=5) # Send a HELO command smtp_conn.ehlo() # Send a MAIL FROM command smtp_conn.mail('cornatul@apple.com') # Send a RCPT TO command for the email address status, _ = smtp_conn.rcpt(email) # Check if the email address was accepted by the SMTP server if status == 250: return f"{email} exists" except: # Print an error message if there was a problem connecting to the SMTP server continue finally: # Close the SMTP connection smtp_conn.quit() else: return f"{email} does not exist" except: return f"Could not validate {email}" Intrebarea la ce risc ma expun nu vreau sa intru in probleme cu isp-ul Quote
Kev Posted May 9, 2023 Report Posted May 9, 2023 https://docs.directadmin.com/other-hosting-services/preventing-spam/outgoing-spam.html Quote