import datetime import smtplib import ssl from email.mime.text import MIMEText import sys, codecs
sys.stdout = codecs.getwriter("utf-8")(sys.stdout) gmail_account = "" # → Please enter your email address. gmail_password = "" # → Please enter your e-mail address and password. gmail to = "" # → Please enter the email address you want to send. send_name = "Pooyan"
today_date = datetime.date.today() delivery_date = today_date + datetime.timedelta(days=7) print(today_date,delivery_date)
subject = "{0}, we will send you a purchase order for {1}.". Format (send_name, today_date)
body = "We will send you the purchase order with the title.
Please check the attached file.
The delivery date for this order will be {0}.
Puyan Co., Ltd.". Format (delivery_date )
print (subject) # For confirmation
print (body) #for confirmation
msg = MIMEText(body, "html") print(msg)
msg["Subject"] = subject msg["To"] = mail_to msg["From "] = gmail_account print(msg)
server = smtplib.SMTP_SSL("smtp.gmail.com", 465,context=ssl.create_default_context()) server.login(gmail_account, gmail_password) server.send_message(msg) server.close() print ('send completed')
Recommended Posts