Topic: Stripping Header From MIME? Issues With Relay
==== REQUIRED BASIC INFO OF YOUR IREDMAIL SERVER ====
- iRedMail version (check /etc/iredmail-release): 0.9.8
- Linux/BSD distribution name and version: Debian
- Store mail accounts in which backend (LDAP/MySQL/PGSQL): LDAP
- Web server (Apache or Nginx): Nginx
- Manage mail accounts with iRedAdmin-Pro? Yes (3.1)
- [IMPORTANT] Related original log or error message is required if you're experiencing an issue.
====
We have a Global Relay enabled and we use MailGun (this fact is important). For the account in question we have Forwarding setup so every email that gets sent to admin@domain.com gets forwarded into another system, via the MailGun relay.
This has worked seamlessly for us until the forwarding mechanism stopped working for emails from a certain address (lets call them 'Company A'). The emails would arrive in the appropriate inbox in iRedMail but they would not be forwarded to the other system. When I looked into the logs regarding this issue, this is what I found:
Aug 29 21:43:42 mail-iredadmin postfix/smtp[12683]: 1CCBB2E5BA: to=<forwarded_address@domain.com>, relay=smtp.mailgun.org[52.26.214.90]:2525, delay=0.36, delays=0.03/0.01/0.19/0.13, dsn=5.0.0, status=bounced (host smtp.mailgun.org[52.26.214.90] said: 554 Rejected: specified IP can't be used to send the message. (in reply to end of DATA command))
MailGun was denying this message, but all of the other dozens of messages using the same relay/forward settings were not having any issues at all.
After going back and forth with MailGun several times here is there summary of why they are denying the relay:
- The email being relayed (from Company A) is also being sent from MailGun (essentially Company A is also using a MailGun relay to send their email).
- a MIME header in the email included instructions on what MailGun IP address Company A wants to use when sending me the email: X-Mailgun-Sending-Ip: 166.78.69.127
- When iRedMail receives the email from Company A, it is set to forward the message using our own MailGun relay.
- When iRedMail relays this message using MailGun, MailGun is seeing the header instructions: X-Mailgun-Sending-Ip: 166.78.69.127 BUT these were the instructions that Company A sent to their MailGun account
- Our MailGun account looks for that IP address to relay with, but since that is Company A's MailGun IP address and not a MailGun IP address we own...our MailGun account denies the relay
TLDR: The message sent from company A included instructions to their MailGun account on what IP to use. These instructions are being passed through to our MailGun account when we relay the message but since we don't own that IP address MailGun denies the relay. So essentially any messages we receive from another MailGun provider are not going to be relayed for us.
The thing I don't quite understand is why MailGun is placing precedence on the MIME Header in the email vs the Relay settings we define in iRedMail. But maybe that doesn't matter.
I am a beginner when it comes to any of this so I hope that explanation was sufficient.
MY REQUEST:
MailGun has told me that I need to "Strip this header from the MIME" before relaying it through our MailGun account. How can I go about accomplishing this?
Any help would be greatly appreciated. Thanks for your time!
----
Spider Email Archiver: On-Premises, lightweight email archiving software developed by iRedMail team. Supports Amazon S3 compatible storage and custom branding.