I am new to django-cron and am trying to send a mail over regular intervals. I've been running the following in the db shell:
from django.core.mail import EmailMessage
email = EmailMessage('Subject', 'Body', to=['address@mail.com'])
email.send()
which works fine. I've created the following cron.py in one of my apps:
from django_cron import CronJobBase, Schedule
from django.core.mail import EmailMessage
class SendMail(CronJobBase):
RUN_EVERY_MINS = 1
schedule = Schedule(run_every_mins=RUN_EVERY_MINS)
code = 'apps.appname.cron.SendMail'
def job(self):
email = EmailMessage('Subject', 'Body', to=['address@mail.com'])
email.send()
In my settings I have:
CRON_CLASSES = [
"apps.appname.cron.SendMail",
]
and finally in the command line I'm running
env/bin/python manage.py runcrons --settings=settings.dev
I was hoping that this would send the mail every minute but although I'm not seeing any command line errors the mail isn't being sent.
Any help greatly appreciated
C