Last active
September 22, 2024 19:09
-
-
Save AlexLynd/fbfaa2f1f3ab9c257adf5c52ce67700f to your computer and use it in GitHub Desktop.
A timed Python script to send reminder emails.
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
# 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.') |
thx, helpful as a basic boilerplate
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Code exercise I wrote 4 a friend to remind him what items he is carrying.