This is a design note from a Laravel email platform we build. It sends campaigns through several SMTP accounts at once. The interesting part is not the round robin. It is deciding when an account is safe to use and when to stop using it. The code below is simplified from our own implementation. We do not publish deliverability numbers here because we have not measured them for this article.
The rules we ended up with
- Each message goes out From the sending account’s own SMTP username. Rotation does not let you put an arbitrary From address on every account, because providers can reject or rewrite mail when the login does not match the sender.
- Rotation needs at least two eligible accounts. With fewer, the option is not offered.
- An account is eligible only if it passes one shared check, used by the dispatch validation, the review screen and the sender assignment, so the three can never disagree.
- Authentication failures pause an account. Other failures do not.
- Only a person resumes a paused account.
One eligibility check, used everywhere
An account is rejected with a readable reason if it is paused, has no host, has an invalid port, or its username is not a valid email address:
public function problems(EmailService $service): array
{
$problems = [];
if ($service->smtpHealth?->paused_at) {
$problems[] = 'SMTP account is paused after repeated authentication failures';
}
if (blank($service->settings['host'] ?? null)) {
$problems[] = 'SMTP host is missing';
}
// port range and username-is-an-email checks follow the same pattern
return $problems;
}
Because the reasons are returned as a list, the review screen can show an operator exactly why an account is excluded instead of silently dropping it from the pool.
Which failures count against an account
We classify errors into categories and keep only the category, never the raw exception text, so credentials cannot end up in a log or table. Authentication failures are recognised from the SMTP reply codes 530, 534 and 535 and the enhanced codes 5.7.8, 5.7.9 and 5.7.14, and from common message wording.
A different kind of permanent rejection, such as a 5xx for one recipient, is counted separately. It does not establish that the account’s credentials are bad, so it does not move the account toward a pause.
Pause after three in a row
public const AUTH_PAUSE_THRESHOLD = 3;
// on an authentication failure
$health->consecutive_auth_failures++;
if ($health->consecutive_auth_failures >= self::AUTH_PAUSE_THRESHOLD) {
$health->paused_at ??= now();
}
// on a successful send
$health->consecutive_auth_failures = 0;
The counter is consecutive, so one transient failure followed by a success does not accumulate. Three failures in a row pause the account.
Two details matter:
- A late success from a message that was already in flight does not resume a paused account. A pause stays visible to the operator until someone acts.
- Resuming is explicit. The operator confirms the credentials were fixed, and that resets the counter. The state changes run inside a database transaction with a row lock on the account, so two workers failing at the same moment cannot race on the first insert.
IMAP is tracked separately
The same accounts are also read over IMAP to pick up replies. We track IMAP failures in their own columns. An IMAP outage or a bad IMAP login never pauses sending and never changes the SMTP counters. Mixing the two would stop outbound mail because of an inbound problem.
Related settings from our own setup
These are choices we made, not recommendations for everyone: a daily cap of 100 messages per sending account for campaigns, copy generated per contact by a local model through a queue so generation runs one message at a time, and campaigns that default to draft review so nothing sends before a person looks at it.
Checklist
- Make eligibility one function that returns reasons.
- Send From the account’s own address.
- Count only authentication failures toward a pause, and make the count consecutive.
- Store failure categories, not raw error text.
- Never auto-resume a paused account.
- Keep inbound and outbound health separate.