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 the primary account API key or one of your Domain Sending Keys).
For our SMTP server, you need to use your domain's SMTP credentials.
Note: If the API keys are not visible within your Control Panel, verify your permissions with your account's Admin user.
Primary Account API Key
When you sign up for Mailgun, we generate a primary account API key. This key allows you to perform all CRUD operations via our various API endpoints and for any of your sending domains. To view your API key:
- Click on Settings on the left-hand side of the Mailgun dashboard.
- Select API Keys from the menu below on the left-hand side.
- On the following page, under the API Keys section, you'll see your Private API key.
- Click on the eye icon to make the full API key visible.
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. In order to create a sending API key:
- Click on the Sending drawer on the left-hand side of the Mailgun dashboard
- Click on Domains, select the domain in which you wish to add a sending key to
- Click on Domain Settings and navigate to the Sending API keys tab
- Click on Add Sending Key
- Give your key a suitable description (such as the name of the application or client you're creating the key for) and click Create Sending Key
- 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.
Your SMTP credentials are different for each domain you add. You can find your default credentials, and add more, by clicking through to your domain settings.
Inside the Mailgun Control Panel (options displayed down the left-hand side on a dark column), the SMTP Credentials are not visible and can only be reset. To update your SMTP credentials, use the following instructions:
- Click on Sending on the left-hand side of your the Mailgun dashboard and select Domains.
- Select your desired domain.
- Click on Domain Settings, then click on the SMTP credentials tab.
- To update the password click Reset Password.
- Confirm your password reset by clicking Reset Password in the pop-up.
- Your SMTP credential's new password will be displayed on the top-right corner within a green pop-up. Save this password by clicking on the copy button and pasting into a safe location, as it will not be revealed again.
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 on ports check out our blog post.
If any questions arise, just reach out to our Support team via the Support tab in your Mailgun control panel!