Sending email notification halt frappe.enqueue

I have a web form with this code in the custom py file:

	def after_insert(self):

And I have setup email notification on the Settings>Notification with trigger after_insert

This code works well when email notification is not active.
When notification is active, the code stops at after doing validation again (there is def validate before this def after_insert).
But the email is still sent.

If I set the trigger at New, the enqueue is working. But the subsequent code which has frappe.get_doc('doctype':'CustomDT') (which get data from the webform) said the doctype is not found.
Which actually the doctype has been saved when validation is done.
And the email is also still sent.
This is the error I got:

2020-10-20 09:13:05 rq.worker ERROR: handle_exception 839 frappe.exceptions.DoesNotExistError: CustomDT {'filename': 'fielddata'} not found

And this is the last line of traceback:

frappe.exceptions.DoesNotExistError: CustomDT {'filename': 'fieldata'} not found

Did I do it wrong or is there any reason the code is stop?

Just now I tried to send email by code using this code:

def send_email(email_address):
		subject="Subject of the email",
		message= "Content of the email"

and run it with bench execute on terminal.
I got this error:

WARNING	Property: Unknown Property name. [11:3: overflow-wrap]

Actually, one line of the traceback on my above post also showing this warning.

And to my surprise, the email is still sent :slight_smile:

Can anyone please shed some light on this warning and maybe suggest a solution?

I can send email using this script. But it is very slow compared to using the Settings>Notifications. I don’t know if it was slow on the code response or between the server and smtp (I use gmail).

I’d be greatful if someone can give advice on better way to send email.