IMAP sync stages new user if Group.incoming_email is not set to Group.email_username

While playing around with IMAP sync a staged user was created for Group.email_username during import from the IMAP account.
Trying to understand what happened I noticed that Group.find_by_email does not take Group.email_username into account requiring to set Group.incoming_email to include this value at least.

Repro steps:

  • enable IMAP sync
  • configure Email sync options on a group but leave Group.incoming_email unconfigured
  • send a mail to Group.email_username
1 Like

I believe IMAP is still a bit of a work in progress @sam?

It should be reasonable supported we do use it in production on meta.

@martin can you have a quick look at this report?

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.

5 Likes

This was fixed by FEATURE: Use group SMTP settings for sending user notification emails (initial) by martin-brennan · Pull Request #13220 · discourse/discourse · GitHub, and the group email config UI has gotten a revamp recently. IMAP is still very much in an alpha state though, so use that feature at your own risk.

3 Likes