Skip to content

Instantly share code, notes, and snippets.

@mrtushartiwari
Created November 29, 2021 03:10
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 mrtushartiwari/a80c75ef7135bca353e49e862504cb22 to your computer and use it in GitHub Desktop.
Save mrtushartiwari/a80c75ef7135bca353e49e862504cb22 to your computer and use it in GitHub Desktop.
import smtplib, ssl
port = 465 # For SSL
password = open("secure_pass.txt").read() # your password without newline
TO_EMAIL_ADDRESS = "reciever@gmail.com"
FROM_EMAIL_ADDRESS= "sender@gmail.com"
# Create a secure SSL context
context = ssl.create_default_context()
SUBJECT = "Job done"
TEXT = " Won the task"
email_message = 'Subject: {}\n\n{}'.format(SUBJECT, TEXT)
print(" Before sending")
#smtplib does not support Subject header directly
with smtplib.SMTP_SSL("smtp.gmail.com",
port, context=context) as server:
server.login(FROM_EMAIL_ADDRESS, password)
# TODO: Send email here
server.sendmail(FROM_EMAIL_ADDRESS,
TO_EMAIL_ADDRESS,
email_message )
print(" Mail sent")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment