New guide: how to warm up a dedicated IP without hurting your reputation. Read now →
Log in
MigoSMTP
SecurityUpdated 26 Oct 2026

SMTP IP Allowlisting: Restrict Who Can Send Through Your Relay and Avoid Lockouts

How IP allowlisting for SMTP relay and API access works, when to combine it with authentication, how to find your outbound IPs, handling dynamic and cloud addresses, rotating credentials safely, and troubleshooting blocked connections.

KM
Written by Karan Malhotra
API and Developer Experience Lead
Reviewed by Hannah Mitchell
  • Published26 Jan 2026
  • Read time6 min
  • Length1,279 words
Share this guide

An SMTP relay that accepts connections from anywhere with only a password is a target. Credentials leak through code repositories, logs and phishing, and once they are out an attacker can send spam in your name from any country. IP allowlisting adds a second condition: the connection must come from an address that you have approved. It is one of the simplest ways to reduce the damage of a leaked password, and when it is badly planned it is also one of the simplest ways to cause an outage, because the address that your application uses to reach the internet is not always the one you expect. This guide explains how allowlisting works for SMTP and API access, how it fits with authentication, how to find the correct outbound address in common environments, what to do with dynamic and shared addresses, how to change entries without downtime and how to troubleshoot refused connections.

IdeaAccept SMTP or API requests only from approved source IP addresses or ranges
StrengthLimits the use of stolen credentials to your own network
WeaknessFragile when egress addresses change; useless on shared or dynamic addresses without care
Best practiceUse it together with authentication, not instead of it

Allowlisting and authentication together

The two controls answer different questions. Authentication proves who is connecting; allowlisting limits from where. A relay that relies only on IP trust (sometimes called IP-based relay) authorises any machine on an approved address, which may include other users of a shared network or an infected host. A relay that relies only on a password is exposed to credential theft. Combining them means that an attacker needs both the secret and a foothold on an approved network. Many providers offer this as an optional setting for SMTP credentials and API keys. See API key security, permissions and rotation and sending account security.

Find the address your server really uses

The source address a mail relay sees is the public address of the network edge that your traffic leaves through, not the private address of your server. Check it from the machine that sends:

# From the sending host: which public IP do outbound connections use?
curl -s https://ifconfig.me ; echo
curl -s https://api.ipify.org ; echo

# Compare with what the relay sees: check the connection log or error message

Be aware of what lies between your code and the relay:

EnvironmentOutbound addressAllowlist advice
Single VPS or dedicated serverIts public IPAllow that address
Cloud VM with elastic or static IPThe attached static addressAllow it; keep the static IP attached
Cloud VM with ephemeral IPChanges on stop or restartReserve a static IP first
Private subnet behind a NAT gatewayThe NAT gateway addressAllow the NAT address, which every host in that subnet shares
Serverless functions and containersOften a large changing poolRoute through a NAT with a static IP, or use API keys without IP rules
Office or home networkISP-assigned, may changeAsk for a static address, or use a VPN with a fixed exit
Hosted web app platformShared platform addressesCheck whether the platform offers fixed outbound IPs
IPv4 and IPv6Different addresses for eachAllow the one that your host uses, or both

If your application can reach the relay over both IPv4 and IPv6, the address may differ depending on which is chosen. Test from the production environment, not from a developer laptop.

Setting up an allowlist

  1. Inventory the senders. List every application, server and job that sends mail through the account, and which environment each runs in.
  2. Find their public egress addresses as above, for production, staging and any batch job.
  3. Allow the narrowest ranges. A single address (/32) is better than a whole network. Use ranges only if you control them.
  4. Add entries before you enable enforcement. Some platforms let you run in a log-only mode first. If yours does not, add the entries, send a test from each system and then switch on enforcement.
  5. Use separate credentials per system with their own allowlists. A leaked key from one system then does not work from another.
  6. Document each entry: owner, purpose and date. Entries without an owner are never removed.
  7. Plan emergency access. Make sure that at least two administrators can change the list without needing to send mail through the same system.

Changing addresses without downtime

When you move a server or change a NAT address, add the new address to the allowlist first, move the application, confirm that mail flows and only then remove the old one. If an address must be removed immediately, because of a compromise, accept a short interruption and have a fallback route ready. Keep a calendar reminder for the renewal or release of cloud addresses. Put the list in version control or an infrastructure-as-code tool where the provider has an API, so that changes are reviewed and recorded.

Troubleshooting refused connections

SymptomLikely causeWhat to check
Connection refused or timeout on port 587Firewall at your side or the provider sideTest with openssl s_client -starttls smtp -connect host:587; see SMTP test guide
535 authentication failed from a new serverNew server not in the allowlist, or wrong credentialCheck the source IP the relay logged; see 535 authentication failed
Works from laptop, fails from productionDifferent egress addressAllow the production NAT address
Works for hours, then failsEphemeral cloud IP changedReserve a static address
Intermittent failuresSeveral NAT addresses or load-balanced egressAllow all of them, or force a single route
Relay access deniedSending without authentication from a non-approved addressAuthenticate and allow the address; see relay access denied
API returns 403 from one regionAPI key restricted to specific addressesAdd the address or create a new key for that environment

Also check for timeouts and TLS problems that look the same, see SMTP connection timeouts and TLS errors, and port choice in SMTP ports.

A note on sending IPs versus source IPs

Two different sets of addresses are easy to confuse. The source address is where your application connects from, and it is what an allowlist at the relay checks. The sending address is the IP that the relay uses when it delivers the message to the recipient's mail server, and it is what SPF, blocklists and reputation systems see. Allowlisting your application's address does nothing to change the sending address, and changing your sending IPs, for example by moving to a dedicated pool, does not require a change to the allowlist. Keep the two lists apart in your documentation so that nobody edits the wrong one during an incident. For the sending side, see dedicated vs shared IP.

Monitoring and alerts

Treat refused connections as a signal. A sudden run of attempts from an address you do not know may mean that a credential has leaked and someone is testing it. Ask your provider whether failed attempts are logged and whether you can receive alerts, and review the log after any change to the list. Pair this with alerts on sending volume so that an unusual spike is noticed within minutes, not days.

What allowlisting does not protect

  • An attacker who already controls a machine on the approved network.
  • Applications on shared platforms where many tenants use the same outbound address.
  • Messages sent through your own user mailboxes by phishing, where the attacker uses a normal mail client and the provider's interface.
  • Misuse by your own code, such as a contact form that can be abused to send to anyone. Rate-limit and validate it.

Use allowlisting as one layer. Pair it with least-privilege keys, separate credentials per system, rotation, alerting on unusual sending volume and a plan for responding to compromise. A leaked credential that cannot be used from outside your network is a very different incident from one that can.

Restrict access to your sending account Create scoped credentials and limit them to the addresses you trust.

Explore the SMTP relay

References and further reading

Frequently asked questions

What is SMTP IP allowlisting?

A control that accepts SMTP or API requests only from approved source IP addresses, usually in addition to a username and password or API key.

Is IP allowlisting enough on its own?

No. Combine it with authentication so that a host on an approved address cannot send without credentials.

Why does my allowlisted server still get refused?

Its outbound public address may differ from the one you allowed, for example because of a NAT gateway or an IPv6 address.

How do I allowlist serverless functions?

Route their outbound traffic through a NAT gateway with a static IP, or use scoped API keys with other protections.

How do I change allowlist entries safely?

Add the new address first, move the application, verify, then remove the old entry.

Topics#ip allowlist#smtp relay#security#authentication#access control
Was this guide helpful?Your answer helps us improve our documentation.

Start sending in minutes.

Create an account, add your domain and send your first email.

Get started Talk to sales