Created
November 29, 2021 03:10
-
-
Save mrtushartiwari/a80c75ef7135bca353e49e862504cb22 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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