config.py : add 2 more options to the server startup
* --email-from : to have an globel email sending address * --smtp-ssl : if smtp server required ssl support ir_actions.py : upgrade email sending procedure misc.py: review email_send_attach procecure to use the new parameters to server bzr revid: mga@tinyerp.com-20080729072804-vfgm40ga3tty5kw1
This commit is contained in:
parent
b9cd479442
commit
c524722e98
|
@ -324,13 +324,13 @@ class actions_server(osv.osv):
|
||||||
if 'action' in localdict:
|
if 'action' in localdict:
|
||||||
return localdict['action']
|
return localdict['action']
|
||||||
if action.state == 'email':
|
if action.state == 'email':
|
||||||
user = "%s@yahoo.co.in," % (config['smtp_user'])
|
user = config['email_from']
|
||||||
subject = action.name
|
subject = action.name
|
||||||
body = action.message
|
body = action.message
|
||||||
if tools.email_send_attach(user, action.address, subject, body) == True:
|
if tools.email_send_attach(user, action.address, subject, body, debug=False) == True:
|
||||||
logger.notifyChannel('email', netsvc.LOG_INFO, 'Email successfully send to : %s' % (user))
|
logger.notifyChannel('email', netsvc.LOG_INFO, 'Email successfully send to : %s' % (action.address))
|
||||||
else:
|
else:
|
||||||
logger.notifyChannel('email', netsvc.LOG_ERROR, 'Failed to send email to : %s' % (user))
|
logger.notifyChannel('email', netsvc.LOG_ERROR, 'Failed to send email to : %s' % (action.address))
|
||||||
return False
|
return False
|
||||||
actions_server()
|
actions_server()
|
||||||
|
|
||||||
|
|
|
@ -34,6 +34,7 @@ import netsvc,logging
|
||||||
class configmanager(object):
|
class configmanager(object):
|
||||||
def __init__(self, fname=None):
|
def __init__(self, fname=None):
|
||||||
self.options = {
|
self.options = {
|
||||||
|
'email_from':False,
|
||||||
'verbose': False,
|
'verbose': False,
|
||||||
'interface': '', # this will bind the server to all interfaces
|
'interface': '', # this will bind the server to all interfaces
|
||||||
'port': '8069',
|
'port': '8069',
|
||||||
|
@ -95,7 +96,9 @@ class configmanager(object):
|
||||||
parser.add_option('--debug', dest='debug_mode', action='store_true', default=False, help='enable debug mode')
|
parser.add_option('--debug', dest='debug_mode', action='store_true', default=False, help='enable debug mode')
|
||||||
parser.add_option("--assert-exit-level", dest='assert_exit_level', help="specify the level at which a failed assertion will stop the server " + str(assert_exit_levels))
|
parser.add_option("--assert-exit-level", dest='assert_exit_level', help="specify the level at which a failed assertion will stop the server " + str(assert_exit_levels))
|
||||||
parser.add_option("-S", "--secure", dest="secure", action="store_true", help="launch server over https instead of http", default=False)
|
parser.add_option("-S", "--secure", dest="secure", action="store_true", help="launch server over https instead of http", default=False)
|
||||||
|
parser.add_option('--email-from', dest='email_from', default='', help='specify the SMTP email address for sending email')
|
||||||
parser.add_option('--smtp', dest='smtp_server', default='', help='specify the SMTP server for sending email')
|
parser.add_option('--smtp', dest='smtp_server', default='', help='specify the SMTP server for sending email')
|
||||||
|
parser.add_option('--smtp-ssl', dest='smtp_ssl', default='', help='specify the SMTP server support SSL or not')
|
||||||
parser.add_option('--smtp-user', dest='smtp_user', default='', help='specify the SMTP username for sending email')
|
parser.add_option('--smtp-user', dest='smtp_user', default='', help='specify the SMTP username for sending email')
|
||||||
parser.add_option('--smtp-password', dest='smtp_password', default='', help='specify the SMTP password for sending email')
|
parser.add_option('--smtp-password', dest='smtp_password', default='', help='specify the SMTP password for sending email')
|
||||||
parser.add_option('--price_accuracy', dest='price_accuracy', default='2', help='specify the price accuracy')
|
parser.add_option('--price_accuracy', dest='price_accuracy', default='2', help='specify the price accuracy')
|
||||||
|
@ -150,7 +153,7 @@ class configmanager(object):
|
||||||
self.options['pidfile'] = False
|
self.options['pidfile'] = False
|
||||||
|
|
||||||
for arg in ('interface', 'port', 'db_name', 'db_user', 'db_password', 'db_host',
|
for arg in ('interface', 'port', 'db_name', 'db_user', 'db_password', 'db_host',
|
||||||
'db_port', 'logfile', 'pidfile', 'secure', 'smtp_server', 'smtp_user', 'smtp_password', 'price_accuracy', 'netinterface', 'netport', 'db_maxconn', 'commit_mode', 'addons_path'):
|
'db_port', 'logfile', 'pidfile', 'secure', 'smtp_ssl', 'email_from', 'smtp_server', 'smtp_user', 'smtp_password', 'price_accuracy', 'netinterface', 'netport', 'db_maxconn', 'commit_mode', 'addons_path'):
|
||||||
if getattr(opt, arg):
|
if getattr(opt, arg):
|
||||||
self.options[arg] = getattr(opt, arg)
|
self.options[arg] = getattr(opt, arg)
|
||||||
|
|
||||||
|
|
|
@ -352,7 +352,10 @@ def email_send_attach(email_from, email_to, subject, body, email_cc=None, email_
|
||||||
from email import Encoders
|
from email import Encoders
|
||||||
|
|
||||||
msg = MIMEMultipart()
|
msg = MIMEMultipart()
|
||||||
|
|
||||||
|
if not ssl:
|
||||||
|
ssl = config['smtp_ssl']
|
||||||
|
|
||||||
msg['Subject'] = Header(subject.decode('utf8'), 'utf-8')
|
msg['Subject'] = Header(subject.decode('utf8'), 'utf-8')
|
||||||
msg['From'] = email_from
|
msg['From'] = email_from
|
||||||
del msg['Reply-To']
|
del msg['Reply-To']
|
||||||
|
|
Loading…
Reference in New Issue