To be able to send email via MailGun SMTP you read this knowledgebase article: Where do I find my MailGun information?
Mailgun supports sending via SMTP. The servers listen on ports 25
, 465
, 587
, and 2525
. Port 465 requires a TLS connection. Ports 25
, 587
, and 2525
require a non-TLS connection but may be upgraded to TLS using the STARTTLS
command.
- Some ISPs are blocking or throttling SMTP port 25. We recommend using #587 instead.
- Google Compute Engine allows port
2525
for SMTP submission. - SMTP send will error with “cannot parse to address” or “cannot parse from address” if the provided email address fails syntax checks in accordance with RFC5321, RFC5322, RFC6854.
Use “plain text” SMTP authentication and the credentials from the domain details page in your Control Panel which can be found by clicking on a domain in the Domains Tab. For enhanced security, use TLS encryption.
Passing Sending Options
When sending a message via SMTP you can pass additional sending options via custom MIME headers listed in the table below.
Header | Description |
---|---|
X-Mailgun-Tag | Tag string used for aggregating stats. See Tagging for more information. You can mark a message with several categories by setting multiple X-Mailgun-Tag headers. |
X-Mailgun-Dkim | Enables/disables DKIM signatures on per-message basis. Use yes or no . |
X-Mailgun-Deliver-By | Desired time of delivery. See Scheduling Delivery and Date Format. |
X-Mailgun-Drop-Message | Enables sending in test mode. Pass yes if needed. See Sending in Test Mode. |
X-Mailgun-Track | Toggles tracking on a per-message basis, see Tracking Messages for details. Pass yes or no . |
X-Mailgun-Track-Clicks | Toggles clicks tracking on a per-message basis. Has higher priority than domain-level setting. Pass yes , no or htmlonly . |
X-Mailgun-Track-Opens | Toggles opens tracking on a per-message basis. Has higher priority than domain-level setting. Pass yes or no . |
X-Mailgun-Require-TLS | Use this header to control TLS connection settings. See TLS Sending Connection Settings |
X-Mailgun-Skip-Verification | Use this header to control TLS connection settings. See TLS Sending Connection Settings |
X-Mailgun-Recipient-Variables | Use this header to substitute recipient variables referenced in a batched mail message. See Batch Sending |
X-Mailgun-Variables | Use this header to attach a custom JSON data to the message. See Attaching Data to Messages for more information. |
X-Mailgun-Delivery-Time-Optimize-Period | Toggles STO on a per-message basis. String should be set to the number of hours in [0- 9]+h format. See Sending a message with STO for details. |
X-Mailgun-Time-Zone-Localize | Toggles TZO on a per-message basis. String should be set to preferred delivery time in HH:mm or hh:mmaa format, where HH:mm is used for 24 hour format without AM/PM and hh:mmaa is used for 12 hour format with AM/PM. See Sending a message with TZO for details. |