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.
For some reason I didn’t find this topic using the search… I guess I panicked!
Thanks you very much for your fast answer!
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>
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.
Yeah, I thought about doing this to get rid of these email domains.
I notice that a Discourse method creates
And in the importer base, it uses
@email.invalid which is slightly different:
Are these two different “dummy domains” both ignored when Discourse must send emails?
Should I replace my non-working domain with
@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… 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
@email.invalid. I can figure out how to do this, I just wonder which “fake” domain to use.
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.
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")
I think I might
UserEmail.where("email like '%@brokendomain.com'").each do |e|
e.update(email: SecureRandom.hex + "@email.invalid)
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.
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
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.
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…
This is special handling by Discourse for anything ending in
.invalid, which is a reserved TLD.
This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.