Workflow email didn’t work

After update to version 15 workflow action email didn’t work and I don’t know why, please help

Hi @OneSpaceerp,

What is the actual issue you are facing? is there any error message or show something?

because we tested in the latest version 15 so we haven’t faced any type of issue.

Hi NCP,

thank you fo your response,
when I tack any action in purchase order I didn’t reesive any email and nothing created at Email Queue

##error Log
{“name”:“ec10046501”,“owner”:“Administrator”,“creation”:“2024-03-05 01:58:56.433599”,“modified”:“2024-03-05 01:58:56.433599”,“modified_by”:“Administrator”,“docstatus”:0,“idx”:0,“seen”:1,“method”:“frappe.workflow.doctype.workflow_action.workflow_action.send_workflow_action_email”,“error”:“Traceback with variables (most recent call last):\n File "apps/frappe/frappe/utils/background_jobs.py", line 216, in execute_job\n retval = method(**kwargs)\n site = ‘default’\n method = <function send_workflow_action_email at 0x7f8148cd57e0>\n event = None\n job_name = ‘<function send_workflow_action_email at 0x7f296dce8790>’\n kwargs = {‘users_data’: [{‘possible_actions’: [{‘action_name’: ‘Approve’, ‘action_link’: ‘PUR-ORD-2024-00055’}, {‘action_name’: ‘Reject’, ‘action_link’: ‘PUR-ORD-2024-00055’}], ‘email’: 'hany.hegazy…\n user = ‘Administrator’\n is_async = True\n retry = 0\n retval = None\n method_name = ‘frappe.workflow.doctype.workflow_action.workflow_action.send_workflow_action_email’\n before_job_task = ‘frappe.monitor.start’\n File "apps/frappe/frappe/workflow/doctype/workflow_action/workflow_action.py", line 375, in send_workflow_action_email\n common_args = get_common_email_args(doc)\n users_data = [{‘possible_actions’: [{‘action_name’: ‘Approve’, ‘action_link’: ‘PUR-ORD-2024-00055’}, {‘action_name’: ‘Reject’, ‘action_link’: ‘PUR-ORD-2024-00055’}], ‘email’: ‘hany.hegazy@biotech-eg.com…\n doc = <PurchaseOrder: PUR-ORD-2024-00055>\n File "apps/frappe/frappe/workflow/doctype/workflow_action/workflow_action.py", line 492, in get_common_email_args\n "attachments": [frappe.attach_print(doctype, docname, file_name=docname, doc=doc)],\n doc = <PurchaseOrder: PUR-ORD-2024-00055>\n doctype = ‘Purchase Order’\n docname = ‘PUR-ORD-2024-00055’\n email_template = <EmailTemplate: Workflow Action>\n subject = ‘Action Required | Purchase Order Approval’\n response = ‘<div class="ql-editor read-mode">

Dear all,


I hope this email finds you well. We have received a purchase order request that requires your attention for approval.

Please review the details below and take the necessary action:


Purchase Order Number: PUR-ORD-.YYYY.-

Supplier: Nest Software Development

Total Amount: 500.0

’\n File "apps/frappe/frappe/init.py", line 2132, in attach_print\n else get_print(doctype, name, **kwargs)\n doctype = ‘Purchase Order’\n name = ‘PUR-ORD-2024-00055’\n file_name = ‘PUR-ORD-2024-00055’\n print_format = None\n style = None\n html = None\n doc = <PurchaseOrder: PUR-ORD-2024-00055>\n lang = None\n print_letterhead = True\n password = \n letterhead = None\n print_language = <function print_language at 0x7f814ab19990>\n scrub_urls = <function scrub_urls at 0x7f814c22f640>\n get_pdf = <function get_pdf at 0x7f8143fa6710>\n print_settings = {‘add_draft_heading’: ‘1’, ‘allow_page_break_inside_tables’: ‘0’, ‘allow_print_for_cancelled’: ‘0’, ‘allow_print_for_draft’: ‘1’, ‘creation’: None, ‘docstatus’: ‘0’, ‘enable_print_server’: ‘0’, ‘enable_raw_printing’: ‘0’, ‘font’: ‘Default’, ‘font_size’: ‘0’, ‘idx’: ‘0’, ‘modified’: ‘2024-01-12 16:55:24.348182’, ‘modified_by’: ‘Administrator’, ‘name’: ‘Print Settings’, ‘owner’: ‘Administrator’, ‘pdf_page_height’: ‘0’, ‘pdf_page_size’: ‘A4’, ‘pdf_page_width’: ‘0’, ‘print_style’: ‘Redesign’, ‘repeat_header_footer’: ‘1’, ‘send_print_as_pdf’: ‘1’, ‘with_letterhead’: ‘1’}\n kwargs = {‘print_format’: None, ‘style’: None, ‘doc’: <PurchaseOrder: PUR-ORD-2024-00055>, ‘no_letterhead’: False, ‘letterhead’: None, ‘password’: '’, ‘as_pdf’: True}\n content = ‘’\n ext = ‘.pdf’\n File "apps/frappe/frappe/init.py", line 2091, in get_print\n return get_pdf(html, options=pdf_options, output=output) if as_pdf else html\n doctype = ‘Purchase Order’\n name = ‘PUR-ORD-2024-00055’\n print_format = None\n style = None\n as_pdf = True\n doc = <PurchaseOrder: PUR-ORD-2024-00055>\n output = None\n no_letterhead = False\n password = ******\n pdf_options = {}\n letterhead = None\n get_pdf = <function get_pdf at 0x7f8143fa6710>\n get_response_content = <function get_response_content at 0x7f8143e24c10>\n html = '\n<html lang="en" dir="ltr">\n\n\t<meta charset="utf-8">\n\t<meta name="viewport" content="width=device-width, initial-scale=1.0">\n\tNest Software Development\n\t<meta name="generator" content="frappe">\n\t<link type="text/css" rel="stylesheet" href="/assets/frappe/dist/css/print.bundle.G5JGSBIR.css">\n\t\n\t\t\n\t\t@media screen {\n\t.print-format-gutter {\n\t\tbackground-color: #d1d8dd;\n\t\tpadding: 30px 0px;\n\t}\n\t.print-format {\n\t\tbackground-color: white;\n\t\tborder-radius: 8px;\n\t\tmax-width: 8.3in;\n\t\tmin-height: 11.69in;\n\t\tpadding: 0.75in;\n\t\tmargin: auto;\n\t\tcolor: var(–gray-900);\n\t}\n\n\t.print-format.landscape {\n\t\tmax-width: 11.69in;\n\t\tpadding: 0.2in;\n\t}\n\n\t.page-break {\n\t\t/ padding: 15px 0px; /\n\t\tborder-bottom: 1px dashed #888;\n\t}\n\n\t/ .page-break:first-child {\n\t\tpadding-top: 0px;\n\t} /\n\n\t.page-break:last-child {\n\t\tborder-bottom: 0px;\n\t}\n\n\t/ mozilla hack for images in tab…\n File "apps/frappe/frappe/utils/pdf.py", line 95, in get_pdf\n frappe.throw(_("PDF generation failed because of broken image links"))\n html = '\n<html dir="ltr" lang="en">\n\t<meta charset="utf-8"/>\n\t<meta content="width=device-width, initial-scale=1.0" name="viewport"/>\n\tNest Software Development\n\t<meta content="frappe" name="generator"/>\n\t<link href="https://biotech.nsd-eg.com/assets/frappe/dist/css/print.bundle.G5JGSBIR.css\" rel="stylesheet" type="text/css"/>\n\t\n\t\t\n\t\t@media screen {\n\t.print-format-gutter {\n\t\tbackground-color: #d1d8dd;\n\t\tpadding: 30px 0px;\n\t}\n\t.print-format {\n\t\tbackground-color: white;\n\t\tborder-radius: 8px;\n\t\tmax-width: 8.3in;\n\t\tmin-height: 11.69in;\n\t\tpadding: 0.75in;\n\t\tmargin: auto;\n\t\tcolor: var(–gray-900);\n\t}\n\n\t.print-format.landscape {\n\t\tmax-width: 11.69in;\n\t\tpadding: 0.2in;\n\t}\n\n\t.page-break {\n\t\t/ padding: 15px 0px; /\n\t\tborder-bottom: 1px dashed #888;\n\t}\n\n\t/ .page-break:first-child {\n\t\tpadding-top: 0px;\n\t} /\n\n\t.page-break:last-child {\n\t\tborder-bottom: 0px;\n\t}\n\n\t/ mo…\n options = {‘print-media-type’: None, ‘background’: None, ‘images’: None, ‘quiet’: None, ‘encoding’: ‘UTF-8’, ‘margin-right’: ‘15mm’, ‘margin-left’: ‘15mm’, ‘header-html’: ‘/tmp/frappe-pdf-a412b19cacf916425ec412feaf3f2e74adde3a937a03bc4fb244ef55.html’, ‘footer-html’: ‘/tmp/frappe-pdf-085da91dbd069ccedcabbda499a547fcfa5caf940f47e3978a00c84e.html’, ‘page-size’: ‘A4’, ‘disable-javascript’: ‘’, ‘disable-local-file-access’: ‘’, ‘load-error-handling’: ‘ignore’, ‘disable-smart-shrinking’: ‘’}\n output = None\n filedata = ‘’\n File "apps/frappe/frappe/init.py", line 578, in throw\n msgprint(\n msg = ‘PDF generation failed because of broken image links’\n exc = <class ‘frappe.exceptions.ValidationError’>\n title = None\n is_minimizable = False\n wide = False\n as_list = False\n File "apps/frappe/frappe/init.py", line 550, in msgprint\n _raise_exception()\n title = None\n as_table = False\n as_list = False\n indicator = ‘red’\n alert = False\n primary_action = None\n is_minimizable = False\n wide = False\n realtime = False\n sys = <module ‘sys’ (built-in)>\n _raise_exception = <function msgprint.._raise_exception at 0x7f8143965fc0>\n _strip_html_tags = <functools._lru_cache_wrapper object at 0x7f814398a350>\n inspect = <module ‘inspect’ from ‘/usr/lib/python3.10/inspect.py’>\n msg = ‘PDF generation failed because of broken image links’\n out = {‘message’: ‘PDF generation failed because of broken image links’, ‘title’: ‘Message’, ‘indicator’: ‘red’, ‘raise_exception’: 1, ‘__frappe_exc_id’: ‘d6134977bdf324b62540c5a4ca0dde230d3ebd76c9c9fea8f38dcb5f’}\n raise_exception = <class ‘frappe.exceptions.ValidationError’>\n strip_html_tags = <function strip_html_tags at 0x7f814c2357e0>\n File "apps/frappe/frappe/init.py", line 501, in _raise_exception\n raise exc\n exc = ValidationError(‘PDF generation failed because of broken image links’)\n inspect = <module ‘inspect’ from ‘/usr/lib/python3.10/inspect.py’>\n msg = ‘PDF generation failed because of broken image links’\n out = {‘message’: ‘PDF generation failed because of broken image links’, ‘title’: ‘Message’, ‘indicator’: ‘red’, ‘raise_exception’: 1, ‘__frappe_exc_id’: ‘d6134977bdf324b62540c5a4ca0dde230d3ebd76c9c9fea8f38dcb5f’}\n raise_exception = <class ‘frappe.exceptions.ValidationError’>\nfrappe.exceptions.ValidationError: PDF generation failed because of broken image links”,“doctype”:“Error Log”,“__last_sync_on”:“2024-03-05T23:17:20.084Z”}

RQ Job

Exception
Traceback (most recent call last):
File “/cloudclusters/erpnext/frappe-bench/env/lib/python3.10/site-packages/rq/worker.py”, line 1428, in perform_job
rv = job.perform()
File “/cloudclusters/erpnext/frappe-bench/env/lib/python3.10/site-packages/rq/job.py”, line 1278, in perform
self._result = self._execute()
File “/cloudclusters/erpnext/frappe-bench/env/lib/python3.10/site-packages/rq/job.py”, line 1315, in _execute
result = self.func(*self.args, **self.kwargs)
File “/cloudclusters/erpnext/frappe-bench/apps/frappe/frappe/utils/background_jobs.py”, line 216, in execute_job
retval = method(**kwargs)
File “/cloudclusters/erpnext/frappe-bench/apps/frappe/frappe/workflow/doctype/workflow_action/workflow_action.py”, line 375, in send_workflow_action_email
common_args = get_common_email_args(doc)
File “/cloudclusters/erpnext/frappe-bench/apps/frappe/frappe/workflow/doctype/workflow_action/workflow_action.py”, line 492, in get_common_email_args
“attachments”: [frappe.attach_print(doctype, docname, file_name=docname, doc=doc)],
File “/cloudclusters/erpnext/frappe-bench/apps/frappe/frappe/init.py”, line 2132, in attach_print
else get_print(doctype, name, **kwargs)
File “/cloudclusters/erpnext/frappe-bench/apps/frappe/frappe/init.py”, line 2091, in get_print
return get_pdf(html, options=pdf_options, output=output) if as_pdf else html
File “/cloudclusters/erpnext/frappe-bench/apps/frappe/frappe/utils/pdf.py”, line 87, in get_pdf
filedata = pdfkit.from_string(html, options=options or {}, verbose=True)
File “/cloudclusters/erpnext/frappe-bench/env/lib/python3.10/site-packages/pdfkit/api.py”, line 75, in from_string
return r.to_pdf(output_path)
File “/cloudclusters/erpnext/frappe-bench/env/lib/python3.10/site-packages/pdfkit/pdfkit.py”, line 201, in to_pdf
self.handle_error(exit_code, stderr)
File “/cloudclusters/erpnext/frappe-bench/env/lib/python3.10/site-packages/pdfkit/pdfkit.py”, line 155, in handle_error
raise IOError(‘wkhtmltopdf reported an error:\n’ + stderr)
OSError: wkhtmltopdf reported an error:
Exit with code 1 due to network error: HostNotFoundError

Perhaps, problem with workflow emails not working seems to be caused by a broken image link within the email template, which is preventing the PDF generation process. This error occurs because It use a tool called wkhtmltopdf to convert HTML content to PDF, and it’s encountering a network error due to being unable to resolve a host name. To fix this, you need to ensure all image links in the email template are correct and accessible, and check the network configuration to ensure proper connectivity and DNS resolution. Additionally, verifying the installation of wkhtmltopdf version.

Hi NCP
Many thanks I found that the issue was that the users attach documents to purchase orders as private and that was the issue and after convert this documents to public the email sent but now the emails sent to all users so could I do anything to let this emails sent only to how must tack the next action only

You need, to assume that if the workflow state is “Approved,” an email will be sent. right?
To set this up, use the Notification doctype. Explore it and add the condition accordingly.

Reference:

Thank You!

I have users type such as “Creators”, “Marketing”, “Brand Manager” and so on when creator create purchase order the email of next action must only sent to Marketing not to all users, what done now that the email of next action sent to “Creators”, “Marketing” and “Brand Manager”

Hi @OneSpaceerp,

Please check it and set your according. Also, you can add email in the Recipients if you don’t know.

Thank You!