[fix] Check bulk limit before sending communication. Also improved the bulk limit exceeded message.

This commit is contained in:
Anand Doshi 2015-11-18 15:27:21 +05:30
parent aee558a461
commit 56b6367ebe
2 changed files with 4 additions and 1 deletions

View file

@ -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,

View file

@ -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,