# IMAP sync שלבים משתמש חדש אם Group.incoming\_email אינו מוגדר ל-Group.email\_username

**URL:** <https://meta.discourse.org/t/imap-sync-stages-new-user-if-group-incoming-email-is-not-set-to-group-email-username/178674>\
**Category:** Bug\
**Created:** [6 בפברואר,‏ 2021,‏ 6:18pm UTC](https://meta.discourse.org/t/imap-sync-stages-new-user-if-group-incoming-email-is-not-set-to-group-email-username/178674 "2021-02-06T18:18:29Z")\
**Posts on this page:** 1\
**Showing post:** 5

<div class="post-metadata">

**Author:** ![martin](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/martin/32/491371_2.png) [@martin](https://meta.discourse.org/u/martin)\
**Post date:** [8 בפברואר,‏ 2021,‏ 3:44am UTC](https://meta.discourse.org/t/imap-sync-stages-new-user-if-group-incoming-email-is-not-set-to-group-email-username/178674/5 "2021-02-08T03:44:36Z")

</div>

Thanks @thoka , I had a look into this. I think you are right in that `Group.find_by_email` needs to have the `email_username` added to it, but it is not the cause of the group email user getting staged in this case. This actually happens later on in the receiver where we add other addresses to the newly created topic. The important part here is `should_invite?`

> <https://github.com/discourse/discourse/blob/e9364856f5fb42d8a0fbc0862753f47e76287627/lib/email/receiver.rb#L1244-L1272>

> <https://github.com/discourse/discourse/blob/e9364856f5fb42d8a0fbc0862753f47e76287627/lib/email/receiver.rb#L1274-L1278>

Which in turn compares the email against `group_incoming_emails_regex`:

> <https://github.com/discourse/discourse/blob/e9364856f5fb42d8a0fbc0862753f47e76287627/lib/email/receiver.rb#L948-L950>

I think we will need to make it so in this regex, or another, that we compare against the `email_username` as well. So far we have not found it a problem that the staged user for the group is made, though I can see that it looks a little messy/unnecessary. I will need to do some testing when I change this to make sure the staged user for the group is not being made for some important currently unknown (to me) reason.

---

_[View the full topic](https://meta.discourse.org/t/imap-sync-stages-new-user-if-group-incoming-email-is-not-set-to-group-email-username/178674)._
