Ejemplo n.º 1
0
def notify(doc, print_html=None, print_format=None, attachments=None,
	recipients=None, cc=None, fetched_from_email_account=False):
	"""Calls a delayed celery task 'sendmail' that enqueus email in Bulk Email queue

	:param print_html: Send given value as HTML attachment
	:param print_format: Attach print format of parent document
	:param attachments: A list of filenames that should be attached when sending this email
	:param recipients: Email recipients
	:param cc: Send email as CC to
	:param fetched_from_email_account: True when pulling email, the notification shouldn't go to the main recipient

	"""
	recipients, cc = get_recipients_and_cc(doc, recipients, cc,
		fetched_from_email_account=fetched_from_email_account)

	doc.emails_not_sent_to = set(doc.all_email_addresses) - set(doc.sent_email_addresses)

	if frappe.flags.in_test:
		# for test cases, run synchronously
		doc._notify(print_html=print_html, print_format=print_format, attachments=attachments,
			recipients=recipients, cc=cc)
	else:
		check_bulk_limit(list(set(doc.sent_email_addresses)))

		from frappe.tasks import sendmail
		sendmail.delay(frappe.local.site, doc.name,
			print_html=print_html, print_format=print_format, attachments=attachments,
			recipients=recipients, cc=cc, lang=frappe.local.lang, session=frappe.local.session)
Ejemplo n.º 2
0
def notify(doc, print_html=None, print_format=None, attachments=None,
	recipients=None, cc=None, fetched_from_email_account=False):
	"""Calls a delayed celery task 'sendmail' that enqueus email in Bulk Email queue

	:param print_html: Send given value as HTML attachment
	:param print_format: Attach print format of parent document
	:param attachments: A list of filenames that should be attached when sending this email
	:param recipients: Email recipients
	:param cc: Send email as CC to
	:param fetched_from_email_account: True when pulling email, the notification shouldn't go to the main recipient

	"""
	recipients, cc = get_recipients_and_cc(doc, recipients, cc,
		fetched_from_email_account=fetched_from_email_account)

	doc.emails_not_sent_to = set(doc.all_email_addresses) - set(doc.sent_email_addresses)

	if frappe.flags.in_test:
		# for test cases, run synchronously
		doc._notify(print_html=print_html, print_format=print_format, attachments=attachments,
			recipients=recipients, cc=cc)
	else:
		check_bulk_limit(list(set(doc.sent_email_addresses)))

		from frappe.tasks import sendmail
		sendmail.delay(frappe.local.site, doc.name,
			print_html=print_html, print_format=print_format, attachments=attachments,
			recipients=recipients, cc=cc, lang=frappe.local.lang, session=frappe.local.session)
Ejemplo n.º 3
0
 def validate_send(self):
     if self.get("__islocal"):
         throw(_("Please save the Newsletter before sending"))
     check_bulk_limit(self.recipients)
Ejemplo n.º 4
0
	def validate_send(self):
		if self.get("__islocal"):
			throw(_("Please save the Newsletter before sending"))
		check_bulk_limit(self.recipients)