First time here? Check out the FAQ!
2

How does askbot send email notifications?

I configured the mailbox in settings.py file for email settings and its working fine.

I was checking the askbot code for email alerts ( send_email_alerts) and how askbot email-alerts work.

But, I did not understand how -- the email-alert concept works!

I have doubts -

  1. Posting the answer Submit-Button takes a lot of time in cases where - there are users subscribed/following that question via email.

    • Is this slow because on-submit, the email is not sent asynchronously? (should I use celery for background email sending?)
  2. what is the purpose of that cron job? i.e send_email_alerts?

    • What does that cron job do? Should I configure that separately?

thanks.

pajju's avatar
565
pajju
asked 2013-10-16 09:47:35 -0600, updated 2013-10-16 09:50:37 -0600
edit flag offensive 0 remove flag close merge delete

Comments

I also see such a problem, that answer posting takes really long (up to 15 seconds). After the answer was posted, I see instantly the e-mail, so the e-mail sending process may be the problem. But the comment takes only short time period... what happens when I have 100+ subscriptions for my whole forum..

Toms's avatar Toms (2013-10-17 08:21:20 -0600) edit

@Toms Agreed. I think the issue is sending emails, not in the background. So it takes 10secs to submit a new answer, if email-notify was set to instant! @Evgeny should confirm this. I'm waiting for his thoughts.

pajju's avatar pajju (2013-10-17 08:32:55 -0600) edit

@pajju how did you setup email notification? Can you provide some information?

SocialQA's avatar SocialQA (2013-12-11 19:54:24 -0600) edit
add a comment see more comments

1 Answer

4

Hi.

Basically notifications work in two ways:

Instant Notification

This is sent if the user has "instantly" selected in the subscription tab on his profile .

Askbot can be configured to use Celery to queue the email sending task, so the issue of posting taking a long time is solved this way, information about this in the oficial documentation.

If you don't use celery your site may take a long time to post new content because the emails will be sent synchronously and if you have many users with this option selected, an email will be sent to each subscribed user at that time, so that's why it takes a long time to post content.

Daily/Weekly Notifications

This is done with the send_email_alerts management command as a cronjob, this cronjob needs to be configured to make it work.

There is a sample cronjob file on the repository this cronjob needs to be run daily and it will send the notifications according to the user's configuration.

Note: in this cronjob command you might want to include Django's clearsessions management command to delete old session data and save space on the database (info here)

Fitoria's avatar
1.1k
Fitoria
answered 2013-10-17 12:30:19 -0600
edit flag offensive 0 remove flag delete link

Comments

Perfect. perfect. Perfect. Answer.! :)

pajju's avatar pajju (2013-10-17 12:47:29 -0600) edit

currently its happening synchronously. Can't we do that with a separate Thread? i.e Why should we wait for that Email-event to happen? I mean the HTTP response should be sent back to the user immediately(instead of waiting for those events to happen) . And Email-Instant delivery option can be better handled with a separate thread. Right? @Evgeny @Fitoria @Toms

pajju's avatar pajju (2013-10-17 12:56:26 -0600) edit

@pajju not sure about if that is doable, but celery works just fine and it solves that issue, also the sending tweet feature uses Celery (if my mind does not fails).

Fitoria's avatar Fitoria (2013-10-17 12:57:56 -0600) edit

I've used celery. Celery is a big process by itself to manage. I'll check that code and how the pieces work together. Again thanks for confirming the expected behavior of notifications. Should help me better understand and explore Codebase. ;) @Fitoria

pajju's avatar pajju (2013-10-17 13:07:26 -0600) edit
add a comment see more comments