Skip to content

Instantly share code, notes, and snippets.

@syntaxhacker
Created November 22, 2021 18:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save syntaxhacker/769ac4cc43e4d500afb974f67caddf42 to your computer and use it in GitHub Desktop.
Save syntaxhacker/769ac4cc43e4d500afb974f67caddf42 to your computer and use it in GitHub Desktop.
send emails to gmail via python
username='' #email
password='' #password
import smtplib
from email.mime.text import MIMEText
import config
smtp_ssl_host = 'smtp.gmail.com' # smtp.mail.yahoo.com
smtp_ssl_port = 465
username = config.username
password = config.password
sender = username
targets = ['stlig@xlsmail.com']
server = smtplib.SMTP_SSL(smtp_ssl_host, smtp_ssl_port)
server.login(username, password)
longText = """Space Exploration Technologies Corp. (SpaceX) is an American aerospace manufacturer, space transportation services and communications company headquartered in Hawthorne, California. SpaceX was founded in 2002 by Elon Musk with the goal of reducing space transportation costs to enable the colonization of Mars. SpaceX manufactures the Falcon 9 and Falcon Heavy launch vehicles, several rocket engines, Dragon cargo, crew spacecraft and Starlink communications satellites."""
for i in range(20,46):
# msg = MIMEText(longText)
msg = MIMEText('Hi, how are you today?')
msg['Subject'] = f"Hello{i}"
msg['From'] = sender
dest = [targets[0].split('@')[0]+ str(i) + '@' + targets[0].split('@')[1]]
msg['To'] = ', '.join(dest)
server.sendmail(sender, dest, msg.as_string())
server.quit()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment