import os import smtplib from email.mime.multipart import MIMEMultipart from email.mime.text import MIMEText from email.mime.base import MIMEBase from email import encoders class MailKeker: def __init__(self): # Load configurations safely from environment variables self.server = os.getenv("SMTP_SERVER") self.port = int(os.getenv("SMTP_PORT", 587)) self.user = os.getenv("EMAIL_USER") self.password = os.getenv("EMAIL_PASSWORD") def send_email(self, to_email, subject, body, attachment_path=None, is_html=False): # Create the container email message msg = MIMEMultipart() msg['From'] = self.user msg['To'] = to_email msg['Subject'] = subject # Attach the body text or HTML layout msg_type = 'html' if is_html else 'plain' msg.attach(MIMEText(body, msg_type)) # Handle file attachments if present if attachment_path and os.path.exists(attachment_path): filename = os.path.basename(attachment_path) with open(attachment_path, "rb") as attachment: part = MIMEBase("application", "octet-stream") part.set_payload(attachment.read()) encoders.encode_base64(part) part.add_header( "Content-Disposition", f"attachment; filename= filename", ) msg.attach(part) # Execute the secure SMTP connection try: with smtplib.SMTP(self.server, self.port) as server: server.starttls() # Upgrade connection to secure TLS server.login(self.user, self.password) server.sendmail(self.user, to_email, msg.as_string()) print(f"Success: Email successfully sent to to_email") return True except Exception as e: print(f"Error sending email: e") return False if __name__ == "__main__": # Instant initialization block for quick testing keker = MailKeker() keker.send_email( to_email="recipient@example.com", subject="MailKeker Automation Test", body="
Using such scripts without explicit consent can violate privacy laws. The data collected may contain sensitive information, including passwords, personal messages, and financial data. Conclusion MailKeker.py
Ensure your SMTP credentials are correct and that you have enabled "Less secure app access" or are using an "App Password" in Gmail/Outlook. import os import smtplib from email
import dns.resolver def get_mx_record(domain): try: records = dns.resolver.resolve(domain, 'MX') return str(records[0].exchange) except: return None Use code with caution. import dns
This article explores what MailKeker.py is, how it functions, its core features, and the ethical considerations surrounding its deployment. What is MailKeker.py?
Avoid sending thousands of emails rapidly from a standard personal inbox. Rate limits imposed by providers like Gmail will quickly lead to account suspension or IP blacklisting.