Skip to content

Instantly share code, notes, and snippets.

@AlexLynd
Last active September 24, 2021 13:13
Show Gist options
  • Save AlexLynd/fbfaa2f1f3ab9c257adf5c52ce67700f to your computer and use it in GitHub Desktop.
Save AlexLynd/fbfaa2f1f3ab9c257adf5c52ce67700f to your computer and use it in GitHub Desktop.
A timed Python script to send reminder emails.
# https://myaccount.google.com/lesssecureapps
import datetime as dt
from datetime import datetime
import time , smtplib
def send_email(have):
email_user = '***@gmail.com' # email here
server = smtplib.SMTP ('smtp.gmail.com', 587)
server.starttls()
server.login(email_user, '***') # pass here or read from input
message = """\
Subject: Get ur stuff!
\nThings u need to get :
\
"""+ '\n'.join(have)
server.sendmail(email_user, email_user, message)
server.quit()
items = ["jacket", "water bottle", "phone"] # items to notify
have = [] # list of current items
print("(yes/no)")
[have.append(item) for item in items if (input("Do you have your "+item+"? : ").upper() == "YES")]
send = input("What time do you want to be notified (hh:mm) : ").split(":")
print('waiting to send email ...')
curr = [int(numeric_string) for numeric_string in datetime.now().strftime('%Y-%m-%d').split("-")]
send_time = dt.datetime(curr[0],curr[1],curr[2],int(send[0]),int(send[1]),0)
time.sleep(send_time.timestamp() - time.time())
send_email(have)
print('email sent.')
@AlexLynd
Copy link
Author

Code exercise I wrote 4 a friend to remind him what items he is carrying.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment