def send_comm_email(d, name, sent_via=None, print_html=None, attachments='[]', send_me_a_copy=False):
	footer = None

	if sent_via:
		if hasattr(sent_via, "get_sender"):
			d.sender = sent_via.get_sender(d) or d.sender
		if hasattr(sent_via, "get_subject"):
			d.subject = sent_via.get_subject(d)
		if hasattr(sent_via, "get_content"):
			d.content = sent_via.get_content(d)
			
		footer = set_portal_link(sent_via, d)
		
	mail = get_email(d.recipients, sender=d.sender, subject=d.subject, 
		msg=d.content, footer=footer)
	
	if send_me_a_copy:
		mail.cc.append(webnotes.conn.get_value("Profile", webnotes.session.user, "email"))
	
	if print_html:
		mail.add_attachment(name.replace(' ','').replace('/','-') + '.html', print_html)

	for a in json.loads(attachments):
		try:
			mail.attach_file(a)
		except IOError, e:
			webnotes.msgprint("""Unable to find attachment %s. Please resend without attaching this file.""" % a,
				raise_exception=True)
Example #2
0
def add(email, sender, subject, formatted, text_content=None, 
	ref_doctype=None, ref_docname=None):
	"""add to bulk mail queue"""	
	e = webnotes.doc('Bulk Email')
	e.sender = sender
	e.recipient = email
	try:
		e.message = get_email(email, sender=e.sender, formatted=formatted, subject=subject, 
			text_content = text_content).as_string()
	except webnotes.ValidationError:
		# bad email id - don't add to queue
		return
		
	e.status = 'Not Sent'
	e.ref_doctype = ref_doctype
	e.ref_docname = ref_docname
	e.save()
Example #3
0
def sendmail_to_system_managers(subject, content):
	send(get_email(get_system_managers(), None, content, subject))
Example #4
0
def sendmail(recipients, sender='', msg='', subject='[No Subject]'):
	"""send an html email as multipart with attachments and all"""
	
	send(get_email(recipients, sender, msg, subject))