/cloud-scheduler-main.py Secret
Created
July 31, 2021 14:56
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 | |
from email.mime.multipart import MIMEMultipart | |
from email.mime.text import MIMEText | |
from email.mime.application import MIMEApplication | |
def schedule_email(event, context): | |
msg = MIMEMultipart() | |
fromaddr = 'sender@hotmail.com' | |
msg['From'] = fromaddr | |
msg["To"] = "receiver@gmail.com" | |
msg['Subject'] = "Test Report" | |
htmlEmail = """ | |
<p> Dear June, <br/><br/> | |
Please find the attached monthly Report below.<br/><br/> | |
<br/></p> | |
Thank you! <br/><br/> | |
Best Regards, <br/> | |
June </p> | |
<br/><br/> | |
<font color="red">Please do not reply to this email as it is auto-generated via GCP. </font> | |
""" | |
msg.attach(MIMEText(htmlEmail, 'html')) | |
server = smtplib.SMTP('smtp.office365.com', 587) | |
server.starttls() | |
server.login(fromaddr, "password") | |
text = msg.as_string() | |
server.sendmail(fromaddr, ['receiver@gmail.com'], text) | |
server.quit() | |
print("Email are sent successfully!") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment