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

EmailMailgun

Email Problem Overview


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"
}

Email Solutions


Solution 1 - Email

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.

Solution 2 - Email

Whenever a message shows as "Accepted" in the Mailgun logs this indicates that Mailgun has accepted the message and queued it for delivery. The message should be delivered fairly quickly, however it can be queued for a bit of time if you submitted a large amount of messages at once or if the recipient ESP is throttling messages from the IP/domain on your account.

I'd recommend opening a support ticket via your Mailgun account and provide some of the message-ID's so the support team can investigate the exact cause of these delays once the message is submitted to Mailgun.

Solution 3 - Email

The reason why emails are not delivering when sending to the domain name is due to no Routes being on the account. As a note, Flex plans cannot create routes; only Foundation and higher plans may use this feature.

Solution 4 - Email

For guys using the default Mailgun domain who will end up here like I did:

Mailgun did log my email as 'accepted' and 'delivered', however there was no email received in my inbox.

To fix this, you need to authorize the recipient email address: Read More Here

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionDom WeldonView Question on Stackoverflow
Solution 1 - EmailGreg KalekaView Answer on Stackoverflow
Solution 2 - EmailChris HammerView Answer on Stackoverflow
Solution 3 - EmailnourzaView Answer on Stackoverflow
Solution 4 - EmailRichie254View Answer on Stackoverflow