Troubleshooting delayed emails

alt=
DannyA
@dannya
9 years ago
584 posts
I am noticing really long times between a user signup and them receiving confirmation email. Up to 5 minutes in some cases. I am using mailgun and i can see in the logs that the email is sent right after it is received. It seems that the delay is in getting the mail to mailgun. How can I troubleshoot why the mail is taking so long? There is no other mail in the queue.
updated by @dannya: 02/10/16 01:49:40AM
brian
@brian
9 years ago
10,148 posts
Make sure you're looking at the right times in the Mailgun log - you should have 2 events for each email:

"Accepted" - this is when Mailgun has received the email from Jamroom and put it into it's delivery queue

"Delivered" - this is when the actual email delivery happens.

Make sure in your email settings that you're not throttling your email. Note that I think Mailgun is running a bit slow today - it may not be the best day to be testing, as I''m seeing about 60 - 90 seconds on emails delivered today (and JR is sending them out immediately).

Hope this helps!


--
Brian Johnson
Founder and Lead Developer - Jamroom
https://www.jamroom.net
alt=
DannyA
@dannya
9 years ago
584 posts
Yes, Accepted and Delevered are actually within the same minute on jamroom.

However, there is a 4 minute gap between JR ativity log "user has signed up and is pending validation"
and mailgun log "accepted".

This leads me to think that its taking the queue a long time to send the mail to mailgun.
brian
@brian
9 years ago
10,148 posts
DannyA:
Yes, Accepted and Delevered are actually within the same minute on jamroom.

However, there is a 4 minute gap between JR ativity log "user has signed up and is pending validation"
and mailgun log "accepted".

This leads me to think that its taking the queue a long time to send the mail to mailgun.

I'm not aware of anything that would make it take 4 minutes. Are you using a dedicated Mail Server? If so, and it's NOT running on your front end, make sure you're pining it from your Cron Server so it handles the queue's ASAP.

Let me know if that helps.


--
Brian Johnson
Founder and Lead Developer - Jamroom
https://www.jamroom.net
alt=
DannyA
@dannya
9 years ago
584 posts
No I'm using mailgun. And the mail queue is NOT sent to any other server.
brian
@brian
9 years ago
10,148 posts
DannyA:
No I'm using mailgun. And the mail queue is NOT sent to any other server.

If you're not using the mail server, and the emails are being sent directly via Postfix on the server the email is generated from, I'm certain JR is not taking 4 minutes to send it from JR to the local Postfix server.

Check out your local /var/log/maillog - it will let you know.


--
Brian Johnson
Founder and Lead Developer - Jamroom
https://www.jamroom.net
alt=
DannyA
@dannya
9 years ago
584 posts
That helped. Thanks.
alt=
DannyA
@dannya
9 years ago
584 posts
I was wrong. The problem persists. Additionally, I have switched the account communications to use the smtp server instead of mailgun. When I do the email test, it works fine. However, notification emails are taking forever. They are not hitting my mail server for a long time. I see nothing in the activity log other than "user has signed up and is pending validation". The email does not hit the mail server for 6 minutes.
brian
@brian
9 years ago
10,148 posts
There's nothing in Jamroom that makes it wait 6 minutes before sending an email to the local SMTP server. Something is misconfigured on your server OR you have ZERO traffic - since email is sent via a Queue, Queue's are processed when a web process spins up - if you have literally no hits on your site then the queue will not be processed.


--
Brian Johnson
Founder and Lead Developer - Jamroom
https://www.jamroom.net
alt=
DannyA
@dannya
9 years ago
584 posts
brian:
since email is sent via a Queue, Queue's are processed when a web process spins up - if you have literally no hits on your site then the queue will not be processed.

Is there a way to debug this? I don't think there is no traffic. So there might be something else keeping the queue from triggering right away but I can't tell.

One thing to keep in mind is most of my queue operations get sent to my queue server. This is the only thing that does NOT.
brian
@brian
9 years ago
10,148 posts
The way you would debug it is:

1) Do something that sends an email
2) check that the email queue us created in the jr_jrcore_queue table
3) watch for a worker ID to pick it up and work it

The time between #2 and #3 should be at the most a few seconds. You can also watch the queue viewer - look at the queue latency and see if anything is being worked.

Let me know if that helps.


--
Brian Johnson
Founder and Lead Developer - Jamroom
https://www.jamroom.net

Tags