Error in sending mail which are set in Hooks

I have scheduled many schedulers. Normal mail sending while saving the form is working. Whichever I have set the hooks, If mail sending is there Mail is not going and in scheduler it is getting failed.

The error I got is
ImportError: cannot import name ‘HeaderWriteError’ from ‘email.errors’ (/usr/lib/python3.10/email/errors.py)

but I checked in errors.py and HeaderWriteError is present.

Traceback with variables (most recent call last):
File “apps/frappe/frappe/core/doctype/scheduled_job_type/scheduled_job_type.py”, line 125, in execute
frappe.get_attr(self.method)()
self = <ScheduledJobType: email.send_due_date_emails_vbd>
File “apps/frappe/frappe/init.py”, line 1672, in get_attr
return getattr(get_module(modulename), methodname)
method_string = ‘fi_finance.fi_finance.doctype.vendor_billing_discount.email.send_due_date_emails_vbd’
app_name = ‘fi_finance’
modulename = ‘fi_finance.fi_finance.doctype.vendor_billing_discount.email’
methodname = ‘send_due_date_emails_vbd’
File “apps/frappe/frappe/init.py”, line 1414, in get_module
return importlib.import_module(modulename)
modulename = ‘fi_finance.fi_finance.doctype.vendor_billing_discount.email’
File “/usr/lib/python3.10/importlib/init.py”, line 126, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
name = ‘fi_finance.fi_finance.doctype.vendor_billing_discount.email’
package = None
level = 0
File “”, line 1050, in _gcd_import
name = ‘fi_finance.fi_finance.doctype.vendor_billing_discount.email’
package = None
level = 0
File “”, line 1027, in find_and_load
name = ‘fi_finance.fi_finance.doctype.vendor_billing_discount.email’
import
= <function _gcd_import at 0x7b665bf33400>
module = Traceback (most recent call last):
File “env/lib/python3.10/site-packages/traceback_with_variables/core.py”, line 222, in to_cropped_str
raw = print
(obj)
File “apps/frappe/frappe/utils/init.py”, line 327, in dict_printer
if key in v:
TypeError: argument of type ‘object’ is not iterable

What is the solution for it?

It due to a regression caused by a recent Python update.
To resolve this issue, please follow these steps:

bench setup requirements --python
bench build
bench migrate
bench restart

1 Like

Thank you. It is working fine now.