Emails stuck in Email Queue

I just got ERPNext setup and I can get automated emails like password resets, sent immediately (using sendgrid).

However when ever I create a email to a user, it gets stuck in the Email Queue. I can go in and hit “Send Now” and then it goes out.

root@nerdUniversity:/home/frappe/frappe-bench# bench doctor
-----Checking scheduler status-----
Workers online: 3
-----embroiderynerduniversity.com/ Jobs-----

I’ve ran bench enable-scheduler to ensure the scheduler is running, and also checked the process status.

● supervisor.service - Supervisor process control system for UNIX
     Loaded: loaded (/lib/systemd/system/supervisor.service; enabled; vendor preset: enabled)
     Active: active (running) since Sun 2022-10-23 01:33:46 UTC; 40min ago
       Docs: http://supervisord.org
   Main PID: 8073 (supervisord)
      Tasks: 38 (limit: 2324)
     Memory: 357.6M
        CPU: 50.766s
     CGroup: /system.slice/supervisor.service
             ├─8073 /usr/bin/python3 /usr/bin/supervisord -n -c /etc/supervisor/supervisord.conf
             ├─8074 "/usr/local/bin/redis-server 127.0.0.1:13000" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" >
             ├─8075 "/usr/local/bin/redis-server 127.0.0.1:11000" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" >
             ├─8076 "/usr/local/bin/redis-server 127.0.0.1:12000" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" >
             ├─8077 /home/frappe/frappe-bench/env/bin/python /home/frappe/frappe-bench/env/bin/gunicorn -b 127.0.0.1:8000 -w 3>
             ├─8078 /usr/bin/node /home/frappe/frappe-bench/apps/frappe/socketio.js
             ├─8083 /home/frappe/frappe-bench/env/bin/python -m frappe.utils.bench_helper frappe schedule
             ├─8088 /home/frappe/frappe-bench/env/bin/python -m frappe.utils.bench_helper frappe worker --queue default
             ├─8093 /home/frappe/frappe-bench/env/bin/python -m frappe.utils.bench_helper frappe worker --queue short
             ├─8094 /home/frappe/frappe-bench/env/bin/python -m frappe.utils.bench_helper frappe worker --queue long
             ├─8121 /home/frappe/frappe-bench/env/bin/python /home/frappe/frappe-bench/env/bin/gunicorn -b 127.0.0.1:8000 -w 3>
             ├─8122 /home/frappe/frappe-bench/env/bin/python /home/frappe/frappe-bench/env/bin/gunicorn -b 127.0.0.1:8000 -w 3>
             └─8123 /home/frappe/frappe-bench/env/bin/python /home/frappe/frappe-bench/env/bin/gunicorn -b 127.0.0.1:8000 -w 3>

Same problem. Did you figure it out?

By default when you send an email through frappe.sendmail() By default value in that function is delayed=True
For send an email instantly without being in queue you can just pass delayed=False

frappe.sendmail(
    recipients=recipients,
    subject=frappe._('Birthday Reminder'),
    template='birthday_reminder',
    args=dict(
        reminder_text=reminder_text,
        birthday_persons=birthday_persons,
        message=message,
    ),
    header=_('Birthday Reminder'),
    delayed=False
)

Can you check the background jobs and list all the failed queues.

yoursite/app/background_jobs

It sounds like the scheduler may be disabled for your site. You can run bench doctor to see if you have a backed-up job queue, or bench --site site.name enable-scheduler to turn the scheduler on.

Yes Its Work Fine with sendemail method, but How can we Archive the Same Thing for Notification Email Alert Thank You

Hi @riddhi1 ,

I’m facing the same issue as yours. did you find any solution for that?