我想知道是否可以在特定日期之前发送电子邮件?为了进一步解释一下,我们每个月的第二个星期三都会举行会谈,他们有一个标题和演讲者。
我想在每次会议前 2 周(即每月的第一天)向成员发送电子邮件(存储在成员对象中的电子邮件地址),但仍可获取本月的谈话。那么这可能吗?每次谈话的日期都存储在谈话对象中。电子邮件的基本大纲仅包含本月谈话对象中的信息。
I am wondering if it is possible to send an email before a certain date? To explain a bit more we have talks that run every month on the second Wednesday of the month and they have a title and speaker.
I would like to email the members (email addresses stored in member object) 2 weeks before each meeting so on the first of the month yet get this months talk. So is this possible? The dates for each talk are stored in the talk objects. The basic outline of the email would just consist of the information in this months talk object.
发布评论
评论(2)
您可以使用 cron 作业,或者更好的是消息队列服务,例如 RabbitMQ 或 ZeroMQ。 Celery 是一个将这些消息队列服务包装在 python/django 模块中的项目。
它的工作方式是编写一个函数来执行数据库查询并确定要发送哪些消息。然后,您可以将此函数装饰为任务并为其设置延迟执行时间。
You can use a cron job or, better yet, a message queuing service such as RabbitMQ or ZeroMQ. Celery is a project that wraps these message queuing services in a python/django module.
The way it would work is you'd write a function that would do your database queries and figure out which messages to send. You'd then decorate this function as a task and set a delayed execution time on it.
编写自定义管理命令,持续一个月talk 对象,检查是否有安排在接下来的两周进行的会谈并向正确的成员发送电子邮件,然后运行该命令 每天使用 cron 作业。
Write a custom management command, that goes over the month talk objects, checks if there are talks scheduled for the next two weeks and sends email to the right members, and then run that command using a cron job every day.