Can't send Bulk Email (Error: please run connect() first)

I’m getting this error on the ‘Bulk Emails’ (please run connect() first)
Any ideas?

I found that after a mail get the error
Connection unexpectedly closed
the rest of all the mails get the error
please run connect() first

But I am not quite sure where is the problem…in the DB or the Mail Server

Where are you getting this error?

Can you share the full trace?

I don’t know how to get the full trace but I can tell you that is when the schedule_event frappe.email.bulk.flush is executed then after 4 or 5 emails sent, the next email has the error Connection unexpectedly closed and all the rest email get the error please run connect() first.
I’m thinking that the function flush should be updated because after an error like that is raised, all the rest of the bulk emails won’t be send because will get the please run connect() first error.
I assume that the problem is coming from the frappe.db because the rest of the affected email doesn’t updated the status to Sending.
I made a custom patch to set back the status of ‘Not Send’ to all the emails that have those two errors.

Yeah.

https://github.com/frappe/erpnext/issues/3232