Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

IMAP/POP3 just sync to one in group of email accounts #19370

Open
khanhtranchi opened this issue Dec 19, 2022 · 4 comments
Open

IMAP/POP3 just sync to one in group of email accounts #19370

khanhtranchi opened this issue Dec 19, 2022 · 4 comments
Labels

Comments

@khanhtranchi
Copy link

khanhtranchi commented Dec 19, 2022

Information about bug

I have 2 email accounts are attached to 2 users:

I sent email to 2 email addresses above.
I'm using IMAP and set sync option to ALL to pull emails from mail server. After pulling email, email appears on one of these accounts above. The rest account email are seen (pull by worker job), but these emails don't appear its Inbox

image

Module

CRM

Version

FRAPPE_VERSION=v14.18.1
ERPNEXT_VERSION=v14.10.1

Installation method

docker

Relevant log output / Stack trace / Full Error Message.

https://github.com/frappe/frappe/blob/bbcc365a2467467761b138d130af487492862fa5/frappe/email/receive.py
image

image

I think that may be we get the message-id, and doesn't include email account id to combine them as key. I try by sending 1 email to 2 email accounts, and 2 message-id are the same. So instead of insert this email for each email account, we just insert 1.

I don't have enough knowledge to involve deeper. Hope someone expert can confirm this case.

Thanks

@khanhtranchi khanhtranchi changed the title IMAP sync missing some emails IMAP/POP3 sync missing some emails Dec 19, 2022
@michalls01
Copy link

@khanhtranchi Hi, it seems that V14 syncs only unread emails. Could it be this #19059 issue?

@khanhtranchi khanhtranchi changed the title IMAP/POP3 sync missing some emails IMAP/POP3 sync to one in group of email account Dec 20, 2022
@khanhtranchi
Copy link
Author

khanhtranchi commented Dec 20, 2022

@khanhtranchi Hi, it seems that V14 syncs only unread emails. Could it be this frappe/frappe#19059 issue?

I am in another situation. After spent time for investing, I find out that When 1 email is sent to group of email accounts in the system, just one of them insert to docs, the other ignore. May be the error comes from the check existing algorithm

@khanhtranchi khanhtranchi changed the title IMAP/POP3 sync to one in group of email account IMAP/POP3 just sync to one in group of email accounts Dec 20, 2022
@deepeshgarg007 deepeshgarg007 transferred this issue from frappe/erpnext Dec 20, 2022
@this-gavagai
Copy link
Contributor

This is a pretty nasty bug, and it is likely related to how v14 deals with the UNREAD flag as documented here:
#19059

@AndreasBBS
Copy link

This is a pretty nasty bug, and it is likely related to how v14 deals with the UNREAD flag as documented here: #19059

This is related to this line of code in my opinion and not #19059:
https://github.com/frappe/frappe/blob/2e007b1ec8b9cce4a1d65a19c64a8438397e7be5/frappe/email/receive.py#L690C39-L690C39

When I have forwarding enabled on my server the same email is redistributed through multiple accounts.

It's the same email, with the same message_id. A lot of email servers don't create a new email with "FW: " that they then send to the forward recipients. This is the case for my email server, it just shares the same email with multiple accounts. When you check if that message_id already exists (like you do in this line of code) it will work for the first recipient but it will fail for all others and it will be associated with only one account. (In fact I noticed it gets associated with the account that is first in alphabetical order of the recipients and this in my opinion has to do with the syncing going through the email counts in alphabetical order)

I suggest this checks if the message_id already exists for the current Email Account (which is easy to get from self.email_account)

I can submit a pull request with this fix if you guys agree with this solution. It's impacting me and I'd like to see this resolved ASAP. Thanks

AndreasBBS added a commit to AndreasBBS/frappe that referenced this issue Dec 30, 2023
…ion record is created when associated with a different email account

📝 chore(test_records.json): add test email account 2 for test_email_account.py
🐛 fix(receive.py): fix find_one_by_filters method to filter by email account as well
The test_mail_exist_validation test case was not correctly checking if a communication record is created. The fix ensures that the communication record is created only if the mail is not already downloaded into that specific Email Account.

A new test case was added to test_mail_exist_validation to check if a communication record is created when the mail is associated with a different email account.

The test_records.json file was updated to include a new test email account, "Email Account 2", for the test_email_account.py test cases.

The find_one_by_filters method in receive.py was fixed to correctly filter by both the message_id and email_account, ensuring that the correct communication record is found.

Closes frappe#19370, closes frappe#23189
AndreasBBS added a commit to AndreasBBS/frappe that referenced this issue Jan 1, 2024
fix(test_email_account.py): modify test case to check if communication record is created when associated with a different email account

chore(test_records.json): add test email account 2 for test_email_account.py
fix(receive.py): fix find_one_by_filters method to filter by email account as well
The test_mail_exist_validation test case was not correctly checking if a communication record is created. The fix ensures that the communication record is created only if the mail is not already downloaded into that specific Email Account.

A new test case was added to test_mail_exist_validation to check if a communication record is created when the mail is associated with a different email account.

The test_records.json file was updated to include a new test email account, "Email Account 2", for the test_email_account.py test cases.

The find_one_by_filters method in receive.py was fixed to correctly filter by both the message_id and email_account, ensuring that the correct communication record is found.

Closes frappe#19370, closes frappe#23189
AndreasBBS added a commit to AndreasBBS/frappe that referenced this issue Jan 2, 2024
fix(test_email_account.py): modify test case to check if communication record is created when associated with a different email account

chore(test_records.json): add test email account 2 for test_email_account.py
fix(receive.py): fix find_one_by_filters method to filter by email account as well
The test_mail_exist_validation test case was not correctly checking if a communication record is created. The fix ensures that the communication record is created only if the mail is not already downloaded into that specific Email Account.

A new test case was added to test_mail_exist_validation to check if a communication record is created when the mail is associated with a different email account.

The test_records.json file was updated to include a new test email account, "Email Account 2", for the test_email_account.py test cases.

The find_one_by_filters method in receive.py was fixed to correctly filter by both the message_id and email_account, ensuring that the correct communication record is found.

Closes frappe#19370, closes frappe#23189
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
5 participants