Mailgun: Messages "Accepted" but taking long time to be delivered (or not being delivered)

Dom Weldon picture Dom Weldon · Sep 24, 2014 · Viewed 23.1k times · Source

I'm using Mailgun for a site I maintain, usually Mailgun works great, but I am encountering a strange problem. My script calls the HTTP API to send messages using Mailgun, these then show up in my log as being "accepted", but then take a very long time to be "delivered", often failing to be delivered at all and simply remaining as "accepted". Has anyone experienced a similar error or could anyone suggest a way to fix it? I'm guessing it's in the arguments supplied to the API but I can't for the life of me figure out the problem.

The problem exists for different recipient domains and different times of day.

The JSON log of a problematic message is below. I have, of course, changed addresses and domains.

{
    "tags": [], 
    "timestamp": 1411498829.247304, 
    "envelope": {
        "targets": "[email protected]", 
        "transport": "", 
        "sender": "[email protected]"
    }, 
    "recipient-domain": "address.com", 
    "event": "accepted", 
    "campaigns": [], 
    "user-variables": {}, 
    "flags": {
        "is-authenticated": true, 
        "is-system-test": false, 
        "is-test-mode": false
    }, 
    "message": {
        "headers": {
            "to": "[email protected]", 
            "message-id": "[email protected]", 
            "from": "\"the-site-in-question.com\" <[email protected]>", 
            "subject": "Dom, your password was reset."
        }, 
        "attachments": [], 
        "recipients": [
            "[email protected]"
        ], 
        "size": 556
    }, 
    "recipient": "[email protected]", 
    "method": "http"
}

Answer

Greg Kaleka picture Greg Kaleka · Aug 14, 2015

If this is happening regularly, it is very likely Mailgun has you on one of their low-tier IP addresses. I imagine this is the default for free accounts, since they don't want to "pollute" their good addresses with new users who may not be serious / legit.

You can check the "quality" of the IP address at a site like Sender Score. Find this line in the Mailgun log of a delivered message:

"sending-ip": "XXX.XX.XXX.XXX"

If Sender Score shows a score in the 70s, that's your problem. Send Mailgun a support ticket, as Chris suggested, and see if they can get you onto a higher quality IP address. I did so and my emails are now being sent from an IP address with a score in the 90s. Haven't had a single delay since.