【问题标题】:Is there any way to send mails regulary using Sendgrid?有没有办法使用 Sendgrid 定期发送邮件?
【发布时间】:2021-10-09 10:33:24
【问题描述】:

我想每月向登录我网站的用户发送通知。我曾想过使用 Sendgrid 的营销活动来发送每月邮件,但它并不完全符合我的需求。我必须在一个月的时间内不断将电子邮件添加到自动化中,这似乎不是正确的做法。

【问题讨论】:

  • 一个在 cron 作业上运行的简单脚本就可以解决问题。
  • 我不知道 cron 作业是什么,但我会检查一下。谢谢
  • cron 基本上是 Linux 默认自带的调度器。您可以使用它定期运行脚本。希望this 有所帮助。
  • 我尝试使用link 中给出的 cron,但是当我运行命令“python manage.py crontab add”时出现“fcntl”的模块错误。在进一步搜索中,我了解到该模块适用于 Linux 操作系统,而我使用的是 Windows。有什么办法可以解决吗??

标签: django sendgrid


【解决方案1】:

使用芹菜。

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

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2022-01-23
    • 2021-06-12
    • 2011-11-02
    • 2017-12-26
    • 2013-10-19
    • 2018-05-19
    相关资源
    最近更新 更多