Scheduling a time in the future to send an email in Java or Python

后端 未结 6 1820
执笔经年
执笔经年 2021-01-27 05:11

I\'m writing an application and I\'d like it to somehow schedule an email to be sent at a later date (likely an hour after it is run). The programming language will be Python or

6条回答
  •  南方客
    南方客 (楼主)
    2021-01-27 05:38

    Answer 1:

    In Python, use threading.Timer to schedule in the future; use smtplib to send an email. No external library needed.

    Answer 2:

    Sounds like you want the sending program to quit rather than having it wait in the background. You may use cron for this. Alternative just use the unix command sleep and mail:

    $ { sleep 3600; echo "hello world" | mail -s the-subject destination-email; } &
    

    P.S. I don't believe SMTP have anything for you in this case. You are really looking for an MTA that has scheduling feature. Though I'm not familiar with it to make a recommendation.

提交回复
热议问题