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

fix: 'EmailServer' object has no attribute 'imap' #17344

Merged
merged 1 commit into from
Jul 1, 2022

Conversation

skjbulcher
Copy link
Contributor

This PR is intended to fix the following traceback:

Traceback (most recent call last):
  File "apps/frappe/frappe/email/queue.py", line 581, in send_one                        
    smtpserver.email_account.append_email_to_sent_folder(message)
  File "apps/frappe/frappe/email/doctype/email_account/email_account.py", line 834, in append_email_to_sent_folder
    if email_server.imap:                         
AttributeError: 'EmailServer' object has no attribute 'imap'

I have email partially set up on my server (which is experiencing the above traceback): I use a notifications email address for outgoing emails, but I don't have any incoming email address configured, and I don't use imap for anything.

@phot0n
Copy link
Contributor

phot0n commented Jun 29, 2022

So this might've happened because we try to put outgoing mails in sent folder which we use when imap is configured for that email account.

this option might've been checked perhaps 👇 (?)
Screenshot 2022-06-29 at 11 21 29 AM

I think we should not show that option if incoming email and imap is not configured.

Plus I'm also surprised - as getting to that line meant that the incoming server connection was established - since you've said that there was no incoming email account configured 🤯

@skjbulcher
Copy link
Contributor Author

since you've said that there was no incoming email account configured

That is correct. I did have an email account set up at one point for document linking, but it isn't working for reasons both related and unrelated to ERPNext, so I unchecked "Enable Incoming". The only other account I set up is the notifications account, and "Enable Incoming" is unchecked on that account as well.

this option might've been checked perhaps (?)

Hmm. That isn't checked, but "Create Contacts from Incoming Emails" is. Does that have something to do with it?


Does my patch make sense, or are you trying to keep the code from getting that far when incoming emails are disabled?

@phot0n
Copy link
Contributor

phot0n commented Jun 30, 2022

"Create Contacts from Incoming Emails" is. Does that have something to do with it?

I don't think so.

are you trying to keep the code from getting that far when incoming emails are disabled?

You've read my mind 😅 - I would definately like that (makes more sense somehow - please also check that imap is also enabled)

if not (self.enable_incoming and self.use_imap):
    return

Probably this at start of append_email_to_sent_folder (?)

As if you trace where the append_email_to_sent_folder method is being called from - it's only called when that option (the scshot i sent earlier) is enabled (and the email has been successfully sent to atleast 1 recipient).

if smtpserver.append_emails_to_sent_folder and email_sent_to_any_recipient:
smtpserver.email_account.append_email_to_sent_folder(message)

Though I'm very curious as to how the incoming connection was established and how that code was executed when that option ("append email to sent folder") is not checked 👀

@skjbulcher
Copy link
Contributor Author

I think append_emails_to_sent_folder is getting set here:

self.append_emails_to_sent_folder = self.email_account.append_emails_to_sent_folder

image

I believe the setting is based on the domain:

image

I do have "Append Emails to Sent Folder" set on the domain, and I think it's grabbing it from there. However, I feel like my settings all make sense - or am I missing something?

Unfortunately I don't have more time to investigate this today or possibly even next week.

@phot0n
Copy link
Contributor

phot0n commented Jul 1, 2022

I think append_emails_to_sent_folder is getting set here:

ah, i was talking about the method append_email_to_sent_folder 😅 - they both have similar name so it's a bit confusing

I do have "Append Emails to Sent Folder" set on the domain, and I think it's grabbing it from there. However, I feel like my settings all make sense - or am I missing something?

I think this might be the case - that does solve 1 mystery 🤣

I'll push a fix for this. Thanks!!

…imap is turned off

This can happen if email domain is updated - which forcibly updates settings
of all email accounts associated with that email domain
@phot0n phot0n merged commit eba2a99 into frappe:version-13-hotfix Jul 1, 2022
@skjbulcher skjbulcher deleted the pullreq/imap-attr-fix branch July 1, 2022 21:21
hrwX pushed a commit to hrwX/frappe that referenced this pull request Jul 2, 2022
…imap is turned off (frappe#17344)

This can happen if email domain is updated - which forcibly updates settings
of all email accounts associated with that email domain
frappe-pr-bot pushed a commit that referenced this pull request Jul 5, 2022
# [13.35.0](v13.34.0...v13.35.0) (2022-07-05)

### Bug Fixes

* "You viewed/edited/created this" (backport [#17365](#17365)) ([#17402](#17402)) ([3f90b51](3f90b51))
* calendar view set in assign time ([6303a4e](6303a4e))
* don't try appending email to sent folder if enable incoming and imap is turned off ([#17344](#17344)) ([eba2a99](eba2a99))
* don't try appending email to sent folder if enable incoming and imap is turned off ([#17344](#17344)) ([524f9f2](524f9f2))
* email not sent if contain file with current site url (backport [#17250](#17250)) ([#17330](#17330)) ([32a5a6f](32a5a6f))
* enable further translations (backport [#17323](#17323)) ([#17340](#17340)) ([c8a58d4](c8a58d4))
* encode docname when routing ([c8777c5](c8777c5))
* extra notification triggered on value change (backport [#17364](#17364)) ([#17366](#17366)) ([eaf82dd](eaf82dd))
* german translations (backport [#17324](#17324)) ([#17341](#17341)) ([bd702ca](bd702ca))
* Issue sending email with attachement (that are not added by sending users) (fix in version-12 but not in version-13) ([#17293](#17293)) ([e44d4d9](e44d4d9))
* make language, source, translation mandatory (backport [#17396](#17396)) ([#17397](#17397)) ([652e9ef](652e9ef))
* **migrate:** Set touched_tables flag prior to try block ([b4d2d31](b4d2d31))
* **redis:** pass shared param when setting value based on generator (backport [#17322](#17322)) ([#17328](#17328)) ([410066c](410066c))
* refresh tree when the treeview is  loaded (backport [#17383](#17383)) ([#17401](#17401)) ([e2ef990](e2ef990))
* remove bare exceptions ([48d87bc](48d87bc))
* remove duplicate tracebacks (backport [#17385](#17385)) ([#17387](#17387)) ([bf91c91](bf91c91))
* remove spaces from email placeholders ([e427f51](e427f51))
* Replace new usages of placeholders ([c1f3e3f](c1f3e3f))
* Resolve conflicts ([dfec295](dfec295))
* Retain value in the field instance when field is rendered on a dialog w/o doc ([aa737bb](aa737bb))
* shortcut widget title overflowing ([#17399](#17399)) ([dff02cf](dff02cf))
* Skip invalid field in get_print_settings_to_show ([4beb66f](4beb66f))
* Translate strings in public folders too ([af9e402](af9e402))
* update ru translations ([#17404](#17404)) ([561fc51](561fc51))
* Use 'email_open_check' in template ([2237a17](2237a17))

### Features

* add email retry limit in system settings (backport [#17259](#17259)) ([#17336](#17336)) ([a87f156](a87f156))
@frappe-pr-bot
Copy link
Collaborator

🎉 This PR is included in version 13.35.0 🎉

The release is available on GitHub release

Your semantic-release bot 📦🚀

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Sep 10, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants