We're experiencing difficulty. Our engineers are on it. Please check status.mailgun.com for real-time updates.

Where Can I Find My API Key and SMTP Credentials?

Authentication is required any time you wish to relay messages through our platform. When using our API, you need to use one of your account's API keys (either an Account API Key or a Domain Sending Key).

For our SMTP server, you need to use your domain's SMTP credentials.

API Keys

Mailgun Account API Key

Account API Keys provide access to our numerous API endpoints that allow you to view and modify many aspects of your account and domains. In other words, you can programmatically perform nearly all the same tasks using the Mailgun APIs that otherwise would be performed within the Mailgun Control Panel.

Mailgun allows for the creation and use of multiple API Keys on the account. Multiple API Keys are useful for several scenarios such as the two listed below.

  • Segmenting usage by providing a unique key for each of your organization's applications, environments, teams, or departments. When used for this purpose and configured correctly, any problem associated with a single API Key would only impact one application, one environment, one team, or one department instead of all applications, environments, teams, or departments.
  • Periodic rotation of the keys. While an existing API Key remains in use, a new API Key can be created and then used to replace the existing API Key at a pace and urgency that suits your schedule.

Important Note!

The API Key can be seen only once: within a pop-up modal after the key's creation. As such, in addition to configuring the API Key in your sending application(s), store the API Key in a secure location (such as your organization's credential/password manager) for future reference.

Consequently, if you lose the API Key, Mailgun will not be able to view and/or disclose the API Key at a later date. The only solution for this situation is to create a new API Key, configure your sending application(s) with the new API Key, and store the new API Key in a secure location for future reference.

To view the account's API Keys (or more specifically their associated API Key IDs, Descriptions, and Created Dates):

  1. In the top-right corner of the Mailgun Control Panel, click your Profile Menu to expand the drop-down list of options.
  1. Next, click the API Security option. Alternatively, you can use this direct link
  1. The resulting page displays the API Keys tabbed section, which lists the account's API Keys (as well as the Verifications Public Key and HTTP Webhook Signing Key).

Domain Sending Keys

Domain Sending Keys are API keys that only allow sending messages using a POST call via our /messages and /messages.mime endpoints for the domain in which they are created for. We'll show you how to do this below:

  1. First, log in to the Mailgun Control Panel (if you have not already done so).
  2. Then, within the left-hand navigation pane, click the Sending option to expand its list of sub-options.
  3. Next, click the Domain settings suboption, and then click on the Sending API keys tab.
  4. Click the Add sending key button.
  5. In the pop-up modal, enter a suitable description (such as the name of the application or client you're creating the key for) before finally clicking the Create sending key button.
  6. Copy your sending API key and keep it in a safe place. For security purposes, we will not be able to show you the key again. If you lose your key, you will need to create a new key.
Note: Once you add a new Domain Sending Key, they are ready to be used immediately, 
and do not affect usage of your primary API key.

SMTP Credentials

Your SMTP credentials are different for each domain you add. You can find any currently added users, and add more, by clicking through to your domain settings. We'll show you how to do this below:

  1. First, log in to the Mailgun Control Panel (if you have not already done so).
  2. Then, within the left-hand navigation pane, click the Sending option to expand its list of suboptions.
  3. Next, click the Domain settings suboption, and then click on the SMTP credentials tab.
  4. To update the password, click the Reset password button.
  5. Confirm your password reset by clicking the Reset Password button in the pop-up modal.
  6. NOTE: The new SMTP password will be available within a dark-gray notification window that appears in the bottom-right portion of the Control Panel. Save this password in your application and in a secure password manager, as it will not be displayed again

Want to create SMTP credentials using the Domain API? Review this documentation

Need to shorten or otherwise customize your SMTP password?  Check out this article!

What Ports Does Mailgun Support?

Our servers listen on ports 25, 465 (SSL/TLS), 587 (STARTTLS), and 2525.

A few things to note when selecting a port:

  • Some ISPs block or throttle SMTP port 25. We recommend using port 587 instead.
  • Google Compute Engine allows port 2525 for SMTP submission.
  • Mailgun IPs change frequently, we do not recommend setting up firewall restrictions against our IP addresses.
  • See our SMTP documentation in the Users Manual to learn how to configure the most popular SMTP software and email clients to work with Mailgun.

For a more detailed explanation of ports check out our blog post.

Got Questions?

Sinch Mailgun has answers! If you have any concerns or questions, please send us a Support ticket using the Support page within your Mailgun Control Panel.  Our Support Team will be happy to assist!