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

Protecting SMTP Authentication From Brute-Force and Credential-Stuffing Attacks

How attackers guess or reuse SMTP credentials, what the attacks look like in logs, and the layered defences: strong secrets, rate limits, lockouts, fail2ban, OAuth, IP restrictions, monitoring and incident response.

JL
Written by Jonas Lindqvist
Security Engineer
Reviewed by Sana Qureshi
  • Published2 Jun 2025
  • Read time6 min
  • Length1,161 words
Share this guide

Any mail server that accepts logins on a public submission port will be attacked, usually within hours of appearing in internet scans. Automated tools try thousands of passwords against known usernames (brute force), try one common password across many accounts (password spraying) or replay username and password pairs leaked from other services (credential stuffing). When one succeeds, the attacker does not need to break anything else: your server will relay their spam as if it were your customer's mail, your IP addresses land on blocklists and the legitimate user loses access. Defence is a layered job. No single control stops everything, but a handful of inexpensive measures remove most of the risk. This guide explains what the attacks look like, how to recognise them in logs, the layers of protection, how to respond when an account is compromised and how to test your setup. For the client side of authentication see authentication methods and 535 authentication errors.

Attack typesBrute force, password spraying and credential stuffing against submission ports 587 and 465
ImpactCompromised accounts, outbound spam, blocklisting and reputation loss
Core defencesUnique strong secrets, rate limits, temporary blocks, MFA or OAuth where possible, and alerts
ResponseDisable the account, rotate the secret, clear the queue and check blocklists

What the attacks look like

PatternDescriptionWhere you see it
Brute forceMany attempts against one account from one or a few IP addressesHundreds of "authentication failed" lines for one user in minutes
Password sprayingOne or two likely passwords tried against many accounts, slowlyFew failures per account but many accounts, often from many IPs
Credential stuffingLeaked pairs from other breaches tried against your serviceMostly valid usernames, a low failure rate and occasional successes
Distributed attackThousands of IPs, each trying only a few attemptsPer-IP limits do not trigger; look at per-account and global counts
Successful login followed by abuseAttacker logs in and sends bulk mailSudden outbound volume, new recipient domains, queue growth. See mail queue management
# Postfix log examples (format varies)
postfix/smtpd[2211]: warning: unknown[198.51.100.77]: SASL LOGIN authentication failed: UGFzc3dvcmQ6
postfix/smtpd[2211]: warning: unknown[198.51.100.77]: SASL LOGIN authentication failed: UGFzc3dvcmQ6
# Count failures per source in the last hour
grep "authentication failed" /var/log/mail.log | awk -F'[][]' '{print $2}' | sort | uniq -c | sort -rn | head

Layer 1: Make guessing hopeless

  • Unique, long, random secrets. For application accounts, generate 20 or more random characters and store them in a secrets manager. Do not reuse passwords from other systems. For people, enforce length over complexity and block known-breached passwords.
  • Do not use predictable usernames such as admin, info or test with weak secrets. Remove default and demo accounts.
  • Separate credentials per application, so that a leak is contained and revocation is easy. Prefer API keys or per-app SMTP credentials to shared user mailboxes. See API key security and rotating a key.
  • Use stronger authentication where available: OAuth 2.0 tokens instead of passwords for mailbox sending (see SMTP OAuth 2.0), and multi-factor authentication for any web interface.
  • Require TLS before AUTH. Credentials should never cross the network in clear text. See TLS for email.

Layer 2: Limit attempts

ControlHow it worksNotes
Per-IP rate limitAllow only a few failed logins per IP per minute, then delay or blockEasy to evade with many IPs, but removes simple attacks
Per-account lockout or delayAfter N failures, slow responses or temporarily lock the accountAvoid permanent lockouts that let attackers deny service to real users; use increasing delays
Global failure alarmAlert when total failures exceed a baselineCatches distributed attacks
Fail2ban or equivalentWatches logs and adds firewall blocks for abusive IPs for a periodTune thresholds; whitelist your own networks. Use short and escalating bans
Connection limitsCap simultaneous connections per clientReduces resource exhaustion. See connection pooling for legitimate high-volume clients
Tarpit / delay on failureAdd a delay to failed responsesSlows brute force with little effect on real users

Layer 3: Reduce exposure

  • Restrict by network. If your applications send from known addresses, allow the submission port only from those. See SMTP IP allowlists.
  • Use non-public endpoints for internal systems: private networks, VPN or private links.
  • Disable unused ports and protocols such as legacy plaintext ports, and close POP or IMAP if you do not need them on the public internet.
  • Use separate submission and receiving servers so that an attack on one does not affect mail intake.
  • Hide details in banners and error messages, which should not reveal whether a username exists. Return the same response for unknown users and wrong passwords.
  • Keep software patched and review configuration for open relay: authentication is not the only way in. See which SMTP port to use.

Layer 4: Limit the damage of a successful login

Assume some account will be compromised eventually, and make it hard for the attacker to benefit:

  • Per-account sending limits: messages per hour and per day, and recipients per message. An account that normally sends 50 messages should not be able to send 50,000.
  • Per-account sender restrictions: only allow the account to use its own From addresses.
  • Outbound content and rate monitoring: detect sudden spikes, many new recipient domains and bursts after hours.
  • Automatic suspension of an account on strong anomalies, with notification to the owner.
  • Separate streams and pools so that abuse on one account does not damage critical mail. See IP pools.

Monitoring and alerting

SignalThreshold ideaAction
Failed logins per account per 10 minutesMore than 10Investigate; slow or lock
Failed logins per IP per minuteMore than 5Block the IP temporarily
Successful login from a new country or networkAny, for sensitive accountsNotify the owner; require verification
Outbound messages per account per hourAbove 3 times the account's normalThrottle and alert
Queue growthDoubling quicklyCheck for abuse. See mail queue
Blocklist listings of your IPsAnyCheck with the blocklist check
Bounce and complaint spikesAbove baselineInvestigate sender. See abuse mailboxes

If an account is compromised

  1. Disable the account or revoke the credential immediately.
  2. Stop the outflow: hold or delete queued spam by ID after review.
  3. Rotate secrets for the account and anything it could reach, and look for other accounts with the same password.
  4. Check the damage: blocklists, bounce and complaint rates, reports to the abuse mailbox.
  5. Find the cause: reused password, leaked key in a repository, malware on a client, weak default.
  6. Notify the owner, and affected customers where required.
  7. Restore with a new strong secret and tighter limits, and document what you learned. See account compromise response and reputation recovery.

Testing your defences

Check your own logs weekly for failed-login patterns. In a test environment, run an authorised brute-force test against a dummy account to confirm that rate limits and bans trigger and that legitimate users are not locked out. Verify that alerts reach a human, and rehearse the compromise procedure so that disabling an account and clearing the queue takes minutes. Review settings after every software upgrade or configuration change, because defaults sometimes reset.

Strong secrets, sensible limits and good monitoring turn a noisy, constant background attack into a non-event. The aim is not to stop every attempt but to make sure that no attempt leads to a spam run.

Send with protected infrastructure Per-credential limits and abuse monitoring on our relay.

Explore the SMTP relay

References and further reading

Frequently asked questions

How do I tell a brute-force attack from normal failed logins?

Look for many failures per account or per IP in a short time, or many accounts with few failures each. Compare to your baseline.

Is fail2ban enough?

No. It helps against simple attacks, but distributed attacks need per-account limits, strong secrets and monitoring.

Should I lock accounts after failed attempts?

Use increasing delays or temporary locks, not permanent ones, so attackers cannot lock out real users.

What should I do first when an account is compromised?

Disable the credential, stop and review the queue, rotate secrets and check blocklists.

Can OAuth reduce this risk?

Yes. Tokens are scoped and expire, so a stolen password alone does not grant SMTP access where basic authentication is disabled.

Topics#smtp auth#brute force#credential stuffing#fail2ban#monitoring
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