Too many user emails domains not working lead to mailgun domain disabled: what to do?

Hi!

My forum has a lot of imported users that have a specific email domain that doesn’t work anymore.
A few thousand users have such an email address.

It was not an issue until now, but I increased suppress digest email after days value, and my forum sent a lot of digest emails, including to a lof of users having non-working email domains.

It led to too many bounces and mailgun disabled my domain.

What should I do with these accounts to prevent this and fix my issue? A lot of these accounts belong to legit users that didn’t come back to the forum yet. There are not necessarily abandoned accounts.

Because of this issue, users can’t register to the forum until it is fixed.

1 Like

Check out Handling bouncing e-mails

3 Likes

For some reason I didn’t find this topic using the search… I guess I panicked! :sweat_smile:

Thanks you very much for your fast answer!

2 Likes

But if there are a zillion email addresses like bademail.domain, maybe what you want to do is something like

rake posts:remap['bademail.domain', 'no-email.invalid']

as described in Replace a string in all posts. That will make all of those email addresses such that Discourse won’t send to them. Another good solution would be something like

bad=User.find_by_email     <some search that will get them all>
bad.update_all(active: false)

and deactivate all of the users with the known bogus email addresses. Not quite sure how to do the first bit off the top of my head, but it should be easy enough to figure out.

5 Likes

Yeah, I thought about doing this to get rid of these email domains.

I notice that a Discourse method creates @no-email.invalid emails:
https://github.com/discourse/discourse/blob/master/app/services/user_merger.rb#L364

And in the importer base, it uses @email.invalid which is slightly different:
https://github.com/discourse/discourse/blob/master/script/import_scripts/base.rb#L869

  1. Are these two different “dummy domains” both ignored when Discourse must send emails?

  2. Should I replace my non-working domain with @no-email.invalid or @email.invalid, or it doesn’t matter?

@pfaffman, I’m not sure to understand why I should remap in posts instead of changing the user emails:thinking: These email addresses aren’t in posts, unless I’m missing something.

If it is a recommended way, I’d just like to replace my @brokendomains.com addresses in each profile by @no-email.invalid or @email.invalid. I can figure out how to do this, I just wonder which “fake” domain to use.

1 Like

I’m fairly certain that posts:remap remaps that domain across all tables, but they had to put it in some class.

You could also just write your own replacement in the UserEmails table (or whatever it’s called).

I’m fairly certain that whatever.invalid will tell The World that it’s an invalid address and it won’t try to send it.

2 Likes

Neat. So I guess this would do the trick?

User.find_each do |u|
	if u.email.include? "@brokendomain.com"
		u.update(email: SecureRandom.hex + "@email.invalid")
	end
end
1 Like

I think I might

UserEmail.where("email like '%@brokendomain.com'").each do |e|
   e.update(email: SecureRandom.hex + "@email.invalid)
end

Yours could work too, but Im’ not sure if the User model got updated to be able to do a u.email.include? after they moved emails to another model/table.

2 Likes

I tried my script just to see if it was returning the target email addresses and it works.

Your script should be faster than mine since you use a query to select specific email domains instead of looping through all the users.

Thank you very much for your help :+1:

2 Likes

Ooops. Here’s the remap I meant. It’s just

  discourse remap old new

See Change the domain name or rename my Discourse?.

I think that the above would work, but the UserEmails solution is probably a tiny bit better.

2 Likes

Thank you. This is the one I used.
More than 5000 users of a total of 17000 users had such email domains. No wonder the number of bounces when I increased suppress digest email after days

3 Likes

This is special handling by Discourse for anything ending in .invalid, which is a reserved TLD.

3 Likes

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.