learning-unlimited / ESP-Website

A website to help manage the logistics of large, short-term educational programs
82 stars 57 forks source link

Feature Request: Process Emails button #2920

Open nrjean opened 4 years ago

nrjean commented 4 years ago

Current mailer behavior runs esp/dbmail_cron.py for new emails every ~15 minutes and then sends them. This behavior is fine for mass mailing however is a bit of a pain when sending test emails as the user may have to wait up to 15 minutes for their test email to arrive. In the case that changes need to make this can turn into a very lengthy process.

Request would be to add a button that processes emails immediately.

willgearty commented 4 years ago

I think a better way to implement this would be to call dbmail_cron.py when someone submits a commpanel request (or, if that's too much, do that but only if DEBUG=TRUE in the settings). Since dbmail_cron.py prevents itself from running multiple instances at the same time, we don't really need to worry about calling it when it's already running. The only thing is I don't know how we would go about running the script from the commpanel view (it's not like there's anything to import).

willgearty commented 4 years ago

Looks like, based on this stackoverflow Q&A, that we would just need to wrap the contents of dbmail_cron.py with if __name__ == '__main__':. Then just put import dbmail_cron.py wherever we want to run the script.

willgearty commented 4 years ago

Other answers to that question suggest you can just run execfile("dbmail_cron.py").