User Spam - automatic account deletions and domain blacklist

I am seeing a small but consistent number of spam accounts being created on my Discourse forum each day. Many appear to be using fake or invalid email addresses.

I am looking for a way to automate the following process:

  1. A new user creates an account and Discourse sends the activation/verification email.
  2. If the activation email results in a confirmed hard bounce, the unactivated user account is automatically deleted.
  3. The system records the domain of the bounced email address.
  4. If multiple new accounts using the same domain result in hard bounces within a defined period of time, the domain is automatically added to the blocked email domain list.
  5. Common legitimate email providers such as Gmail, Outlook, Yahoo, etc., would need to be excluded from automatic domain blocking.

For example, if several accounts using different email addresses from suspicious-domain.example are created within a few days and all of their activation emails hard bounce, the domain would eventually be blocked from creating additional accounts.

The goal is to use bounce data as another signal for identifying automated spam registrations while automatically cleaning up unactivated accounts created with nonexistent email addresses.

Does Discourse currently have a plugin or existing functionality that can accomplish this? If not, are there hooks available in Discourse’s bounce-handling process that could be used to build a plugin to implement this?

Hello @LotusJeff

Did you have a look at these settings, as I think they will get you some part of the way there:

Configure these settings in /admin/settings/

Setting Suggested Value Effect
purge_unactivated_users_grace_period_days 1 Deletes unactivated accounts in 1 day instead of 14. It is’t instant like asked in #2, but it’s the same effect with a smaller delay.
blocked_email_domains Add known spam TLDs/domains manually Blocks registration from known offenders

For anything fully automated like you ask, I think a plugin would need to be built (or none exists afaik), or you can take a look at the new workflow feature. I don’t know if what you want is possible yet, but it’s updating almost daily so who knows :slight_smile:

For the plugin route, there is an event you could hook in DiscourseEvent.on(:email_bounce)

Also worth looking at Configure VERP to handle bouncing e-mails maybe