try: # Fetch emails messages = fetch_emails(imap_mail) if messages: forward_emails(messages, smtp_server) print("Emails forwarded.") else: print("No emails to forward.") finally: imap_mail.close() imap_mail.logout() smtp_server.quit()
# Configuration TEMP_MAIL_ACCOUNT = 'your_temp_email@gmail.com' TEMP_MAIL_PASSWORD = 'your_temp_password' # You can generate one if needed SMTP_SERVER = 'smtp.gmail.com' SMTP_PORT = 587 IMAP_SERVER = 'imap.gmail.com' IMAP_PORT = 993 FORWARD_TO_ADDRESS = 'your_forwarding_email@example.com' temp mail script
# Connect to IMAP and SMTP imap_mail = connect_imap() smtp_server = connect_smtp() try: # Fetch emails messages = fetch_emails(imap_mail) if
def create_temp_email(length=10): letters = string.ascii_lowercase random_string = ''.join(random.choice(letters) for i in range(length)) return f"{random_string}@{TEMP_MAIL_ACCOUNT.split('@')[1]}" temp mail script