Try ERPNext Buy Support Partners Foundation

Issue TypeError: object of type ‘EmailPolicy’ has no len() - cant send emails

Hi i have just updated to V12 from 11 and send emails i get a issue.
in the log it says
File “/usr/lib/python3.5/email/”, line 49, in _formatparam
if value is not None and len(value) > 0:
TypeError: object of type ‘EmailPolicy’ has no len()

Same problem here

We are facing the same issue

Same here

Traceback (most recent call last):
File “/home/frappe/frappe-bench/apps/frappe/frappe/email/doctype/notification/”, line 329, in evaluate_alert
File “/home/frappe/frappe-bench/apps/frappe/frappe/email/doctype/notification/”, line 123, in send
self.send_an_email(doc, context)
File “/home/frappe/frappe-bench/apps/frappe/frappe/email/doctype/notification/”, line 170, in send_an_email
and attachments[0].get(‘print_letterhead’)) or False))
File “/home/frappe/frappe-bench/apps/frappe/frappe/”, line 487, in sendmail
inline_images=inline_images, header=header, print_letterhead=print_letterhead)
File “/home/frappe/frappe-bench/apps/frappe/frappe/email/”, line 162, in send
File “/home/frappe/frappe-bench/apps/frappe/frappe/email/”, line 183, in add
email_queue = get_email_queue(recipients, sender, subject, **kwargs)
File “/home/frappe/frappe-bench/apps/frappe/frappe/email/”, line 218, in get_email_queue
File “/home/frappe/frappe-bench/apps/frappe/frappe/email/”, line 33, in get_email
emailobj = EMail(sender, recipients, subject, reply_to=reply_to, cc=cc, bcc=bcc, email_account=email_account, expose_recipients=expose_recipients)
File “/home/frappe/frappe-bench/apps/frappe/frappe/email/”, line 75, in init
self.msg_root = MIMEMultipart(‘mixed’, policy=policy.SMTPUTF8)
File “/usr/lib/python3.5/email/mime/”, line 36, in init
MIMEBase.init(self, ‘multipart’, _subtype, **_params)
File “/usr/lib/python3.5/email/mime/”, line 25, in init
self.add_header(‘Content-Type’, ctype, **_params)
File “/usr/lib/python3.5/email/”, line 541, in add_header
parts.append(formatparam(k.replace(’’, ‘-’), v))
File “/usr/lib/python3.5/email/”, line 49, in _formatparam
if value is not None and len(value) > 0:
TypeError: object of type ‘EmailPolicy’ has no len()


Go to /home/frappe/frappe-bench/apps/frappe/frappe/email Folder

Replace the content of with content from:

Run bench restart

And Done.


Hi, thank you but now it says
File “/home/frappe/frappe-bench/apps/frappe/frappe/email/”, line 71, in init
if PY3:
NameError: name ‘PY3’ is not defined

I’m facing this after minor updating v11 and then upgrading to v12. I also updated the email password since I could not get the previously saved password to work (encryption key not found, maybe this was my mistake) so I updated the password for the email account and can successfully save.

thank you very much - this works for me!

1 Like

Thanks - this sorted it out for us too. Nothing hitting our email queue at all.
Completed minor update from 12.7.x up to 12.8.4 which started this.

Hey, this solution is not working for me

Traceback (most recent call last):
File “/usr/local/bin/bench”, line 11, in
load_entry_point(‘bench’, ‘console_scripts’, ‘bench’)()
File “/home/frappe/.bench/bench/”, line 41, in cli
File “/usr/local/lib/python3.5/dist-packages/click/”, line 764, in call
return self.main(*args, **kwargs)
File “/usr/local/lib/python3.5/dist-packages/click/”, line 717, in main
rv = self.invoke(ctx)
File “/usr/local/lib/python3.5/dist-packages/click/”, line 1137, in invoke
return _process_result(sub_ctx.command.invoke(sub_ctx))
File “/usr/local/lib/python3.5/dist-packages/click/”, line 956, in invoke
return ctx.invoke(self.callback, **ctx.params)
File “/usr/local/lib/python3.5/dist-packages/click/”, line 555, in invoke
return callback(*args, **kwargs)
File “/home/frappe/.bench/bench/commands/”, line 26, in restart
restart_supervisor_processes(bench_path=’.’, web_workers=web)
File “/home/frappe/.bench/bench/”, line 519, in restart_supervisor_processes
supervisor_status = subprocess.check_output([‘sudo’, ‘supervisorctl’, ‘status’], cwd=bench_path)
File “/usr/lib/python3.5/”, line 316, in check_output
File “/usr/lib/python3.5/”, line 398, in run
output=stdout, stderr=stderr)
subprocess.CalledProcessError: Command ‘[‘sudo’, ‘supervisorctl’, ‘status’]’ returned non-zero exit status 1