Search code examples
djangosendgrid

Is there any way to send mails regulary using Sendgrid?


I want to send monthly notifications to users that log on to my website. I've thought of using Sendgrid's Marketing campaigns to send monthly mails but it doesn't fit perfectly to my needs. I'll have to keep adding emails to the automation at a month's duration and that doesn't seem the right way to do it.


Solution

  • Use Celery.

    from celery.schedules import crontab
    
    
    def setup_periodic_tasks(app):
        app.conf.beat_schedule = {
            'monthly-email': {
                'task': '[APP NAME].tasks.[FUNCTION NAME]',
                'schedule':
            },
    

    https://docs.celeryproject.org/en/stable/userguide/periodic-tasks.html#crontab-schedules