Created
March 16, 2019 04:21
-
-
Save rounakdatta/79a5243c5b0d8b4051220af2a66d0e9e to your computer and use it in GitHub Desktop.
Programmatically send emails through SMTP using Python (Yandex Mail)
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
def sendReportMail(emailAddress, passwordText, title, content): | |
import smtplib | |
from email.mime.text import MIMEText | |
smtp_ssl_host = 'smtp.yandex.com' # change to your own SMTP host | |
smtp_ssl_port = 465 | |
username = emailAddress | |
password = passwordText | |
sender = emailAddress | |
targets = ['[email protected]'] | |
msg = MIMEText(content) | |
msg['Subject'] = title | |
msg['From'] = sender | |
msg['To'] = ', '.join(targets) | |
server = smtplib.SMTP_SSL(smtp_ssl_host, smtp_ssl_port) | |
server.login(username, password) | |
server.sendmail(sender, targets, msg.as_string()) | |
server.quit() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment