# Importers: What to do when missing email addresses

**URL:** https://meta.discourse.org/t/importers-what-to-do-when-missing-email-addresses/60195
**Category:** Development
**Created:** [March 30, 2017, 9:00pm UTC](https://meta.discourse.org/t/importers-what-to-do-when-missing-email-addresses/60195 "2017-03-30T21:00:54Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![pfaffman](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/pfaffman/32/120154_2.png) [@pfaffman](https://meta.discourse.org/u/pfaffman)
#### Post date: [March 30, 2017, 9:00pm UTC](https://meta.discourse.org/t/importers-what-to-do-when-missing-email-addresses/60195/1 "2017-03-30T21:00:54Z")

</div>

I’m doing a phpBB import. There are a bunch of missing email addresses (apparently because Facebook and others authenticated, but didn’t supply an email address) and a bunch more invalid ones.

The client doesn’t want to have messages from those 12K (of 370K) users all lumped in to `@system`.

One solution I’m considering is modifying `create_users` in `base.rb` to call `create_user` when the email is missing (not sure why `create_users` needed to do that anyway, as create\_user checks too) and then modifying `create_user` to use {discourse\_username}@badmail.domain.com as the email address (Of course there are invalid usernames too, so I’ll go with the Discourse username).

This will mean that these users exist in the system, but if a user is to reclaim the account it’ll require manual intervention from an admin, which this client seems OK with.

### Questions:

- Is there some better way?
- Should I submit a PR?
- How long would such a change take a competent developer?

---

<div class="post-metadata">

### Author: ![gerhard](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/gerhard/32/119479_2.png) [@gerhard](https://meta.discourse.org/u/gerhard)
#### Post date: [March 30, 2017, 9:26pm UTC](https://meta.discourse.org/t/importers-what-to-do-when-missing-email-addresses/60195/2 "2017-03-30T21:26:09Z")

</div>

Just generating an email address won’t be enough. You should definitely disable emails for those users as I’m doing [for anonymous users](https://github.com/discourse/discourse/blob/master/script/import_scripts/phpbb3/importers/user_importer.rb#L94-L99). You could either do this in the base importer or just modify the phpBB importer so that it handles users with missing email addresses similar to anonymous users.

BTW: It’s a good idea to use the [`.invalid` TLD](https://en.wikipedia.org/wiki/.invalid) for generated email addresses (just in case something goes wrong and Discourse starts to send emails to those users). I’m using the following for anonymous users:

```ruby
"anonymous_#{SecureRandom.hex}@no-email.invalid"

```

---

<div class="post-metadata">

### Author: ![codinghorror](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/codinghorror/32/110067_2.png) [@codinghorror](https://meta.discourse.org/u/codinghorror)
#### Post date: [March 30, 2017, 10:16pm UTC](https://meta.discourse.org/t/importers-what-to-do-when-missing-email-addresses/60195/3 "2017-03-30T22:16:02Z")

</div>

Yes what @gerhard said .. when we migrated coding horror comments we used this filler email:

`francis@no-email-found.com`

(where the first name was the first name of the commenter..)
