Sovite.Core.Outbound (sovite v0.6.0)

Copy Markdown View Source

Outbound abuse protection ([outbound]): detects accounts that are probably compromised, from how much of the mail they send fails.

Each recipient an authenticated user's message is queued for counts as sent, and each one that fails for good (and is bounced) as failed, over the last outbound.window. A user with at least outbound.min_failures failures, making up at least outbound.max_failure_percent of what they sent, is suspended for outbound.suspend_time: their MAIL commands get 550 5.7.1. Spam sent from a stolen account goes to many addresses that do not exist, so its failure rate spikes. Sending volume is capped by the user rate limits (rate_limit.user_messages and rate_limit.user_recipients).

Suspensions are kept in memory: restarting Sovite lifts them.

Telemetry

  • [:sovite, :outbound, :suspended] - %{sent, failed}, %{user, suspend_time}

Summary

Functions

Counts count failed recipients of user, and suspends the user if needed.

The options from the config, with the Sovite.Abuse.RateLimit and Sovite.Abuse.Cache (for suspensions) to use. nil when it is off.

Counts count recipients queued for user.

Whether user is suspended.

Functions

failed(opts, user, count)

@spec failed(map() | nil, String.t() | nil, non_neg_integer()) :: :ok

Counts count failed recipients of user, and suspends the user if needed.

opts(arg1, rate_limit, cache)

@spec opts(Sovite.Core.Config.t(), atom() | nil, atom() | nil) :: map() | nil

The options from the config, with the Sovite.Abuse.RateLimit and Sovite.Abuse.Cache (for suspensions) to use. nil when it is off.

sent(opts, user, count)

@spec sent(map() | nil, String.t() | nil, non_neg_integer()) :: :ok

Counts count recipients queued for user.

suspended?(opts, user)

@spec suspended?(map() | nil, String.t()) :: boolean()

Whether user is suspended.