Skip to content

Instantly share code, notes, and snippets.

@thuwarakeshm
Last active March 30, 2024 01:08
Show Gist options
  • Save thuwarakeshm/00f16f8eb2297ee0bf2efb30483627d1 to your computer and use it in GitHub Desktop.
Save thuwarakeshm/00f16f8eb2297ee0bf2efb30483627d1 to your computer and use it in GitHub Desktop.
import argparse
def send_email(email="default@mydomain.abc"):
# All your email sending logics goes here
print(f"Sending email...: to {email}")
if __name__ == "__main__":
parser = argparse.ArgumentParser()
parser.add_argument("-e", "--email", help="Email to send")
args = parser.parse_args()
if args.email:
send_email(args.email)
else:
send_email()
import time
from schedule import repeat, every, run_pending
@repeat(every(10).seconds)
@repeat(every(5).seconds)
def send_email():
# All your email sending logics goes here
print("Sending email...")
while True:
run_pending()
time.sleep(1)
@repeat(every(10).seconds)
@repeat(every(5).seconds, email="thuwarakesh@abc.com")
def send_email(email="default@mydomain.abc"):
# All your email sending logics goes here
print(f"Sending email...: to {email}")
import time
import schedule
def send_email():
# All your email sending logics goes here
print("Sending email...")
schedule.every().day.at("14:45").do(send_email)
while True:
schedule.run_pending()
time.sleep(1)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment