[IMP]
* Check if sender or default email in config file * Add X-Header (help filter on mail client) * Add dynamic X-Header on def method * Correct incoherent reply to when it exists bzr revid: christophe.chauvet@syleam.fr-20090228135340-02gydu6xc009tb1j
This commit is contained in:
parent
b5e2c0a8a2
commit
3ff49ccb09
|
@ -302,7 +302,7 @@ def reverse_enumerate(l):
|
|||
#----------------------------------------------------------
|
||||
# Emails
|
||||
#----------------------------------------------------------
|
||||
def email_send(email_from, email_to, subject, body, email_cc=None, email_bcc=None, reply_to=False, attach=None, tinycrm=False, ssl=False, debug=False, subtype='plain'):
|
||||
def email_send(email_from, email_to, subject, body, email_cc=None, email_bcc=None, reply_to=False, attach=None, tinycrm=False, ssl=False, debug=False, subtype='plain', x_header={}):
|
||||
"""Send an email."""
|
||||
print 'sending', email_from, email_to, subject, body
|
||||
import smtplib
|
||||
|
@ -317,6 +317,9 @@ def email_send(email_from, email_to, subject, body, email_cc=None, email_bcc=Non
|
|||
if not ssl:
|
||||
ssl = config.get('smtp_ssl', False)
|
||||
|
||||
if not email_from and not config['email_from']:
|
||||
raise Exception("No Email sender by default, see config file")
|
||||
|
||||
if not email_cc:
|
||||
email_cc = []
|
||||
if not email_bcc:
|
||||
|
@ -331,7 +334,9 @@ def email_send(email_from, email_to, subject, body, email_cc=None, email_bcc=Non
|
|||
msg['From'] = email_from
|
||||
del msg['Reply-To']
|
||||
if reply_to:
|
||||
msg['Reply-To'] = msg['From']+', '+reply_to
|
||||
msg['Reply-To'] = reply_to
|
||||
else:
|
||||
msg['Reply-To'] = msg['From']
|
||||
msg['To'] = COMMASPACE.join(email_to)
|
||||
if email_cc:
|
||||
msg['Cc'] = COMMASPACE.join(email_cc)
|
||||
|
@ -339,6 +344,15 @@ def email_send(email_from, email_to, subject, body, email_cc=None, email_bcc=Non
|
|||
msg['Bcc'] = COMMASPACE.join(email_bcc)
|
||||
msg['Date'] = formatdate(localtime=True)
|
||||
|
||||
# Add OpenERP Server information
|
||||
msg['X-Generated-By'] = 'OpenERP (http://www.openerp.com)'
|
||||
msg['X-OpenERP-Server-Host'] = socket.gethostname()
|
||||
msg['X-OpenERP-Server-Version'] = release.version
|
||||
|
||||
# Add dynamic X Header
|
||||
for x in x_header.keys():
|
||||
msg['X-OpenERP-%s' % x] = str(x_header[x])
|
||||
|
||||
if tinycrm:
|
||||
msg['Message-Id'] = "<%s-tinycrm-%s@%s>" % (time.time(), tinycrm, socket.gethostname())
|
||||
|
||||
|
|
Loading…
Reference in New Issue