Search code examples
emailmailguniredmail

Mail server rejecting mail (to a domain it controls) sent by MailGun


Here's the setup:

  • iRedMail server setup to send and receive emails. (send hand crafted emails)

  • MailGun service to send emails. (send automated computer generated mail)

Sending mail from MailGun to mail servers other than my iRedMail server instance, are accepted.

Sending mail to my iRedMail server from MailGun, are rejected with status code 450.

Paste below shows a MailGun log entry of an email, sent by MailGun, to my iRedMail server instance.

{
    "severity": "permanent",
    "tags": [],
    "delivery-status": {
        "tls": true,
        "mx-host": "m1.managemun.org",
        "code": 450,
        "description": "",
        "session-seconds": 1.262861967086792,
        "utf8": true,
        "retry-seconds": 14400,
        "attempt-no": 8,
        "message": "4.1.8 <[email protected]>: Sender address rejected: Domain not found",
        "certificate-verified": true
    },
    "recipient-domain": "managemun.org",
    "id": "1GWMCXnjTBKo5MlCth6Faw",
    "campaigns": [],
    "reason": "old",
    "user-variables": {},
    "flags": {
        "is-routed": false,
        "is-authenticated": true,
        "is-system-test": false,
        "is-test-mode": false
    },
    "log-level": "error",
    "timestamp": 1507644954.828214,
    "envelope": {
        "transport": "smtp",
        "sender": "[email protected]",
        "sending-ip": "XXX.XXX.XXX.XX",
        "targets": "[email protected]"
    },
    "message": {
        "headers": {
            "to": "[email protected]",
            "message-id": "[email protected]",
            "from": "ManageMUN <[email protected]>",
            "subject": "Password Reset"
        },
        "attachments": [],
        "size": 1656
    },
    "recipient": "[email protected]",
    "event": "failed"
}

How can I resolve this issue?

If you have any suggestions regarding the setup, please feel free to criticise constructively


Solution

  • The error returned is caused by Sender Address Verification. The recipient server performs a callback to the MX records of the Sender address to verify the envelope.mail-from address <[email protected]>.

    In this case, the recipient server attempts the callback to "mg.managemun.org" but fails due to the subdomain not having MX records. Therefore, by adding Mailgun's MX records to your subdomain, mg.managemun.org, the MX lookups of those email servers will succeed, and the servers will accept your messages. The two MX records for Mailgun are or can be referenced here:

    Value : mxa.mailgun.org
    Priority: 10

    Value : mxb.mailgun.org
    Priority: 10

    **Disclaimer I work at Mailgun