Hello,
I took a look at this chapter:
http://web2py.com/books/default/chapter/29/08/emails-and-sms#Sending-messages-using-a-background-task, and got this to work - Am able to send emails via a background task.
I was wondering how I could make the Auth related emails also to be sent via this background process. Right now, all the Auth emails - verification/password-reset, etc - are sent synchronously from within Auth's functions.
I was thinking of a possibility, but somehow it seemed too contrived
- For example, I define auth.settings.mailer=MyDummyMail()
- MyDummyMail() only inserts the to/subject/body of the email into a database, so that the background task sends it. It doesn't actually send emails.
- The issue with this is that I need access to the auth_user.id value before sending emails via the background task - because I construct the subject/body of the email with some of the auth_user.extra_fields. This user info is not passed by the Auth class to the mail.send anyway.
- Therefore, this MyDummyMail() method won't work for me
The other possibility is to switch off all emailing from Auth classes, by using another DummyMail() class which actually does nothing, and use the onaccept callback to script my email, and its background sending task. But then, not all the Auth methods have a onaccept method. For example, I'll need one for reset password.
Any suggestions on how I can go about this?
Thanks,
Kiran