* add action for email, send email using the tools.email_send_attach method
* ehance email_send_attach method for debug + ssl support bzr revid: mga@tinyerp.com-20080723073317-12l0v1pejz2fks9l
This commit is contained in:
parent
c5c7c2ef07
commit
501d791ea0
|
@ -30,6 +30,7 @@
|
|||
from osv import fields,osv
|
||||
import tools
|
||||
import time
|
||||
from tools.config import config
|
||||
|
||||
class actions(osv.osv):
|
||||
_name = 'ir.actions.actions'
|
||||
|
@ -316,11 +317,17 @@ class actions_server(osv.osv):
|
|||
'cr': cr,
|
||||
'uid': uid
|
||||
}
|
||||
print action.code
|
||||
exec action.code in localdict
|
||||
print localdict.keys()
|
||||
if 'action' in localdict:
|
||||
return localdict['action']
|
||||
if action.state == 'email':
|
||||
user = "%s@yahoo.co.in," % (config['smtp_user'])
|
||||
subject = action.name
|
||||
body = action.message
|
||||
if tools.email_send_attach(user, action.address, subject, body) == True:
|
||||
print 'email send successfully'
|
||||
else:
|
||||
print 'email sending failed'
|
||||
return False
|
||||
actions_server()
|
||||
|
||||
|
|
|
@ -335,7 +335,7 @@ def email_send(email_from, email_to, subject, body, email_cc=None, email_bcc=Non
|
|||
#----------------------------------------------------------
|
||||
# Emails
|
||||
#----------------------------------------------------------
|
||||
def email_send_attach(email_from, email_to, subject, body, email_cc=None, email_bcc=None, on_error=False, reply_to=False, attach=None, tinycrm=False):
|
||||
def email_send_attach(email_from, email_to, subject, body, email_cc=None, email_bcc=None, on_error=False, reply_to=False, attach=None, tinycrm=False, ssl=False, debug=False):
|
||||
"""Send an email."""
|
||||
if not email_cc:
|
||||
email_cc=[]
|
||||
|
@ -359,6 +359,7 @@ def email_send_attach(email_from, email_to, subject, body, email_cc=None, email_
|
|||
if reply_to:
|
||||
msg['Reply-To'] = reply_to
|
||||
msg['To'] = COMMASPACE.join(email_to)
|
||||
print '************', msg['To']
|
||||
if email_cc:
|
||||
msg['Cc'] = COMMASPACE.join(email_cc)
|
||||
if email_bcc:
|
||||
|
@ -375,6 +376,15 @@ def email_send_attach(email_from, email_to, subject, body, email_cc=None, email_
|
|||
msg.attach(part)
|
||||
try:
|
||||
s = smtplib.SMTP()
|
||||
|
||||
if debug:
|
||||
s.debuglevel = 5
|
||||
|
||||
if ssl:
|
||||
s.ehlo()
|
||||
s.starttls()
|
||||
s.ehlo()
|
||||
|
||||
s.connect(config['smtp_server'])
|
||||
if config['smtp_user'] or config['smtp_password']:
|
||||
s.login(config['smtp_user'], config['smtp_password'])
|
||||
|
|
Loading…
Reference in New Issue