[IMP] add reference argument in email_send method for references of send email.

bzr revid: ysa@tinyerp.com-20110223122420-p6b1z9rglae6euwf
This commit is contained in:
Yogesh (OpenERP) 2011-02-23 17:54:20 +05:30
parent a25bae8f19
commit 3723536d5d
1 changed files with 17 additions and 11 deletions

View File

@ -42,6 +42,7 @@ from email.MIMEBase import MIMEBase
from email.MIMEMultipart import MIMEMultipart
from email.Header import Header
from email.Utils import formatdate, COMMASPACE
from email import Utils
from email import Encoders
from itertools import islice, izip
from lxml import etree
@ -514,7 +515,7 @@ def _email_send(smtp_from, smtp_to_list, message, ssl=False, debug=False,
def email_send(email_from, email_to, subject, body, email_cc=None, email_bcc=None, reply_to=False,
attach=None, message_id=None, openobject_id=False, debug=False, subtype='plain', x_headers=None, priority='3',
attach=None, message_id=None, references=None, openobject_id=False, debug=False, subtype='plain', x_headers=None, priority='3',
smtp_server=None, smtp_port=None, ssl=False, smtp_user=None, smtp_password=None):
"""Send an email.
@ -546,11 +547,13 @@ def email_send(email_from, email_to, subject, body, email_cc=None, email_bcc=Non
email_text = MIMEText(email_body or '',_subtype=subtype,_charset='utf-8')
msg = MIMEMultipart()
if message_id:
if not message_id and openobject_id:
message_id = generate_tracking_message_id(openobject_id)
else:
message_id = Utils.make_msgid()
if references:
msg['references'] = references
msg['Message-Id'] = message_id
elif openobject_id:
msg['Message-Id'] = generate_tracking_message_id(openobject_id)
msg['Subject'] = Header(ustr(subject), 'utf-8')
msg['From'] = email_from
del msg['Reply-To']
@ -588,8 +591,11 @@ def email_send(email_from, email_to, subject, body, email_cc=None, email_bcc=Non
part.add_header('Content-Disposition', 'attachment; filename="%s"' % (fname,))
msg.attach(part)
return _email_send(email_from, flatten([email_to, email_cc, email_bcc]), msg, ssl=ssl, debug=debug,
res = _email_send(email_from, flatten([email_to, email_cc, email_bcc]), msg, ssl=ssl, debug=debug,
smtp_server=smtp_server, smtp_port=smtp_port, smtp_user=smtp_user, smtp_password=smtp_password)
if res:
return message_id
return False
#----------------------------------------------------------
# SMS