Merge pull request #58 from anandpdoshi/master

Added a parameter in sendmail to use defs settings for sending email
This commit is contained in:
Anand Doshi 2011-12-11 23:35:31 -08:00
commit 4c9bcb8175
4 changed files with 10 additions and 6 deletions

View file

@ -5,14 +5,14 @@
{
'creation': '2009-05-12 16:43:58',
'docstatus': 0,
'modified': '2011-11-23 13:39:59',
'modified': '2011-12-05 11:45:45',
'modified_by': 'Administrator',
'owner': 'Administrator'
},
# These values are common for all DocType
{
'_last_update': '1321362800',
'_last_update': '1322035799',
'allow_attach': 0,
'allow_copy': 0,
'allow_email': 0,
@ -40,7 +40,7 @@
'subject': 'eval:("<span style=\'color:grey\'>Module: <b>%(module)s</b>, Type: <b>%(doc_type)s</b>, Standard: <b>%(standard)s</b></span>")',
'tag_fields': 'doc_type',
'use_template': 0,
'version': 24
'version': 25
},
# These values are common for all DocField
@ -99,7 +99,7 @@
'no_copy': 0,
'oldfieldname': 'module',
'oldfieldtype': 'Select',
'options': 'Module Def',
'options': 'link:Module Def',
'print_hide': 0,
'report_hide': 0,
'reqd': 1,

View file

@ -116,3 +116,6 @@ backup_link_path = '/var/www/wnframework/backups'
# url to be emailed to the "System Manager" Role to download
# the backup
backup_url = 'http://localhost/backups'
# System TimeZone (should be acceptable by pytz: Recommended format Continent/City)
system_timezone = 'Asia/Kolkata'

View file

@ -19,7 +19,7 @@ def make_html_body(content, template = None):
return template_html % {'content': content}
def sendmail(recipients, sender='', msg='', subject='[No Subject]', parts=[], cc=[], attach=[], send_now=1, reply_to=None, template=None):
def sendmail(recipients, sender='', msg='', subject='[No Subject]', parts=[], cc=[], attach=[], send_now=1, reply_to=None, template=None, from_defs=0):
"""
send an html email as multipart with attachments and all
"""
@ -27,7 +27,7 @@ def sendmail(recipients, sender='', msg='', subject='[No Subject]', parts=[], cc
from webnotes.utils.email_lib.html2text import html2text
from webnotes.utils.email_lib.send import EMail
email = EMail(sender, recipients, subject, reply_to=reply_to)
email = EMail(sender, recipients, subject, reply_to=reply_to, from_defs=from_defs)
email.cc = cc
if msg:

View file

@ -138,6 +138,7 @@ class EMail:
setup the SMTP (outgoing) server from `Control Panel` or defs.py
"""
if self.from_defs:
import webnotes
self.server = getattr(webnotes.defs,'mail_server','')
self.login = getattr(webnotes.defs,'mail_login','')
self.port = getattr(webnotes.defs,'mail_port',None)