I've added a send_email_task to wrap django.core.mail.send_mail -- I'm using it for testing but I think it could be useful in general.
I've used it to test celerybeat. In my local me.py, I added the following setting: CELERYBEAT_SCHEDULE = { "runs-every-30-seconds": { "task": "regluit.core.tasks.send_mail_task", "schedule": datetime.timedelta(seconds=60), "args": ('hi there', 'testing 1, 2, 3', 'raymond.yee@gmail.com', ['raymond.yee@gmail.com']) }, } and then ran django-admin.py celerybeat -l INFO and started getting email sent to me every minute!pull/1/head
parent
55b3e8398e
commit
206c7ebcd4
|
@ -47,6 +47,16 @@ def fac(n, sleep_interval=None):
|
|||
sleep(sleep_interval)
|
||||
return res
|
||||
|
||||
from django.core import mail
|
||||
|
||||
@task
|
||||
def send_mail_task(subject, message, from_email, recipient_list,
|
||||
fail_silently=False, auth_user=None, auth_password=None,
|
||||
connection=None):
|
||||
"""a task to drop django.core.mail.send_mail into """
|
||||
return mail.send_mail(subject, message, from_email, recipient_list, fail_silently, auth_user, auth_password, connection)
|
||||
|
||||
|
||||
from notification.engine import send_all
|
||||
|
||||
@task
|
||||
|
|
Loading…
Reference in New Issue