I have some sample Python code from here https://docs.python.org/2/library/email-examples.html where I can successfully send emails.
# Import smtplib for the actual sending function
import smtplib
# Import the email modules we'll need
from email.mime.text import MIMEText
me = "my@email.com"
you = "your@email.com"
textfile = 'msg.txt'
# Open a plain text file for reading. For this example, assume that
# the text file contains only ASCII characters.
fp = open(textfile, 'rb')
# Create a text/plain message
msg = MIMEText(fp.read())
fp.close()
# me == the sender's email address
# you == the recipient's email address
msg['Subject'] = 'The contents of %s' % textfile
msg['From'] = me
msg['To'] = you
# Send the message via our own SMTP server, but don't include the
# envelope header.
s = smtplib.SMTP('localhost')
s.sendmail(me, [you], msg.as_string())
s.quit()
I'd like to delay sending the email for two days from now. Is there a parameter with smtplib that allows delaying sending the email? I haven't been able to find anything on my own.
If you are on linux you can use cron job.
Smtplib is just a library and the email is sent by the provider you specify. If you can find an email provider that supports sending delayed messages then it's possible
If you can you can run the script and use time.sleep(2 * 24 * 60 * 60) But it means that the script must run for the 2 days