Last active
April 13, 2020 09:14
-
-
Save ljmocic/afaf3cfe0548e5a51f586a5b7af0d7a2 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
# Read more about setting it up: | |
# https://medium.com/@ljmocic/send-an-email-using-python-and-gmail-4ebc980eae9b | |
import smtplib | |
from email.mime.text import MIMEText | |
EMAIL = '' | |
APP_PASSWORD = '' | |
RECEIVER = '' | |
SUBJECT = '' | |
MESSAGE_TEXT = '' | |
message = MIMEText(MESSAGE_TEXT) | |
message['From'] = EMAIL | |
message['To'] = RECEIVER | |
message['Subject'] = SUBJECT | |
try: | |
server = smtplib.SMTP_SSL('smtp.gmail.com', 465) | |
server.ehlo() | |
server.login(EMAIL, APP_PASSWORD) | |
server.sendmail(EMAIL, RECEIVER, message.as_string()) | |
server.close() | |
print('Email sent!') | |
except Exception as e: | |
print(e) | |
print('Something went wrong...') |
It's actually working, Google changed auth for these kinds of scripts.
You can simply generate APP_PASSWORD in order to be able to send mails again.
You can find more on how to do it here: https://link.medium.com/6LbSmeu6g5
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Not working