From 1cf205bf28ebc10a80e9fabf99cd17d5a030dc4e Mon Sep 17 00:00:00 2001 From: Anand Doshi Date: Fri, 24 Aug 2012 15:10:13 +0530 Subject: [PATCH] added sender as argument to bulk send --- py/webnotes/utils/email_lib/bulk.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/py/webnotes/utils/email_lib/bulk.py b/py/webnotes/utils/email_lib/bulk.py index 9e1810c353..0e6b9a77b3 100644 --- a/py/webnotes/utils/email_lib/bulk.py +++ b/py/webnotes/utils/email_lib/bulk.py @@ -25,10 +25,11 @@ import webnotes class BulkLimitCrossedError(webnotes.ValidationError): pass -def send(recipients=[], doctype='Profile', email_field='email', first_name_field="first_name", +def send(recipients=None, sender=None, doctype='Profile', email_field='email', first_name_field="first_name", last_name_field="last_name", subject='[No Subject]', message='[No Content]'): """send bulk mail if not unsubscribed and within conf.bulk_mail_limit""" import webnotes + def is_unsubscribed(rdata): if not rdata: return 1 return rdata[0]['unsubscribed'] @@ -73,9 +74,11 @@ def send(recipients=[], doctype='Profile', email_field='email', first_name_field return fname + ' ' + lname else: return rdata[0][email_field].split('@')[0].title() - + + if not recipients: recipients = [] + if not sender or sender == "Administrator": + sender = webnotes.conn.get_value('Email Settings', None, 'auto_mail_id') check_bulk_limit(len(recipients)) - sender = webnotes.conn.get_value('Email Settings', None, 'auto_mail_id') for r in recipients: rdata = webnotes.conn.sql("""select * from `tab%s` where %s=%s""" % (doctype,