diff --git a/frappe/core/doctype/communication/communication.py b/frappe/core/doctype/communication/communication.py index e7ffed0b27..980fc3f1b3 100644 --- a/frappe/core/doctype/communication/communication.py +++ b/frappe/core/doctype/communication/communication.py @@ -7,6 +7,7 @@ import json from email.utils import formataddr, parseaddr from frappe.utils import get_url, get_formatted_email, cint, validate_email_add, split_emails from frappe.utils.file_manager import get_file +from frappe.email.bulk import check_bulk_limit import frappe.email.smtp from frappe import _ @@ -103,6 +104,8 @@ class Communication(Document): self._notify(print_html=print_html, print_format=print_format, attachments=attachments, recipients=recipients, cc=cc) else: + check_bulk_limit(list(set(self.sent_email_addresses))) + from frappe.tasks import sendmail sendmail.delay(frappe.local.site, self.name, print_html=print_html, print_format=print_format, attachments=attachments, diff --git a/frappe/email/bulk.py b/frappe/email/bulk.py index 35892cf903..e88908c2a1 100644 --- a/frappe/email/bulk.py +++ b/frappe/email/bulk.py @@ -145,7 +145,7 @@ def check_bulk_limit(recipients): monthly_bulk_mail_limit = frappe.conf.get('monthly_bulk_mail_limit') or 500 if (this_month + len(recipients)) > monthly_bulk_mail_limit: - throw(_("Email limit {0} crossed").format(monthly_bulk_mail_limit), + throw(_("Cannot send this email. You have crossed the sending limit of {0} emails for this month.").format(monthly_bulk_mail_limit), BulkLimitCrossedError) def get_unsubscribe_link(reference_doctype, reference_name,