diff --git a/zerver/management/commands/deliver_email.py b/zerver/management/commands/deliver_email.py index 78f7484fd4..9f5681256d 100755 --- a/zerver/management/commands/deliver_email.py +++ b/zerver/management/commands/deliver_email.py @@ -74,7 +74,8 @@ Usage: python manage.py deliver_email with lockfile("/tmp/zulip_email_deliver.lockfile"): while True: # make sure to use utcnow, otherwise it gets confused when you set the time with utcnow(), and select with now() - email_jobs_to_deliver = ScheduledJob.objects.filter(type=ScheduledJob.EMAIL) + email_jobs_to_deliver = ScheduledJob.objects.filter(type=ScheduledJob.EMAIL, + scheduled_timestamp__lte=datetime.utcnow()) if email_jobs_to_deliver: for job in email_jobs_to_deliver: if not send_email_job(job):