0% found this document useful (0 votes)
23 views1 page

Automated Email Sending Script

The document is a Python script that reads email addresses and SMTP server information from text files. It sends emails in a loop using a cycling mechanism for the SMTP servers. The script includes functions for reading files and sending emails with error handling.

Uploaded by

cloki7920
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
23 views1 page

Automated Email Sending Script

The document is a Python script that reads email addresses and SMTP server information from text files. It sends emails in a loop using a cycling mechanism for the SMTP servers. The script includes functions for reading files and sending emails with error handling.

Uploaded by

cloki7920
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd

import smtplib

from itertools import cycle

def read_file(file_path):
with open(file_path, 'r') as file:
return [[Link]() for line in file]

def send_email(smtp_info, sender, recipient, subject, body):


try:
server = [Link](smtp_info['host'], smtp_info['port'])
[Link]()
[Link](smtp_info['username'], smtp_info['password'])
message = f"From: {sender}\nTo: {recipient}\nSubject: {subject}\n\n{body}"
[Link](sender, recipient, message)
[Link]()
print(f"Email sent to {recipient} using {smtp_info['host']}")
except Exception as e:
print(f"Failed to send email to {recipient}: {e}")

def main():
emails = read_file('[Link]')
smtp_servers = read_file('[Link]')
smtp_info_list = [{'host': [Link]()[0], 'port': int([Link]()[1]),
'username': [Link]()[2], 'password': [Link]()[3]} for smtp in smtp_servers]

smtp_cycle = cycle(smtp_info_list)

sender = 'your_email@[Link]'
subject = 'Your Subject Here'
body = 'Your Email Body Here'

for email in emails:


smtp_info = next(smtp_cycle)
send_email(smtp_info, sender, email, subject, body)

if __name__ == "__main__":
main()

You might also like