Closed gsb-eng closed 8 years ago
@dstufft : Could you please add if anything else needs to be considered?
I'll be working on this.
Broadly we can categorize warehouse email requirement into two types.
1) Instant Emails:
Use Cases : Password recovery, registration confirmation, alert when a new maintainer or author added, etc. I think 100% of emails goes through PyPi comes under this category.
Implementation: We can use a celery task to send email asynchronously, Worker should be always running to handle queued tasks.
Handling Failures: If any exception occurs in the first attempt, we've to handle two cases here.
Sample celery task:
@app.task(bind=True,
def send_mail(task, retry=True, max_retries=3):
try:
mailer.send_immediately(message)
except Exception, exc:
if retry:
task.retry(countdown=1, max_retries=max_retries, exc=exc)
raise
2) Scheduled Emails:
Use Cases: News letters, some mass updates, etc.
Implementation: We can use a celery task to send email asynchronously, Worker should run at defined time to handle the queued tasks.
Handling Failures: We can maintain a different queue for the failed tasks and a worker should be running always to handle the failure queue.
Sample celery task:
@app.task(bind=True)
def send_email(task):
try:
mailer.send(message)
except Exception, exc:
send_email(args, queue='failure_queue')
Consensus required on below queries:
@dstufft : Can I close this issue now?
Warehouse doesn't have any send_mail functionality configured, Sending mail is necessary for functionalities like password recovery, user registration confirmation, etc.
Initial thoughts: