Answers for "How do I schedule an email to send at a certain time using cron and smtp, in python"

0

How do I schedule an email to send at a certain time using cron and smtp, in python

import datetime as dt
import time
import smtplib

def send_email():
    email_user = '[email protected]'
    server = smtplib.SMTP ('smtp.gmail.com', 587)
    server.starttls()
    server.login(email_user, 'email pass')

    #EMAIL
    message = 'sending this from python!'
    server.sendmail(email_user, email_user, message)
    server.quit()

send_time = dt.datetime(2018,8,26,3,0,0) # set your sending time in UTC
time.sleep(send_time.timestamp() - time.time())
send_email()
print('email sent')
Posted by: Guest on May-06-2022

Code answers related to "How do I schedule an email to send at a certain time using cron and smtp, in python"

Python Answers by Framework

Browse Popular Code Answers by Language