Commit 3104706f authored by Jérome Perrin's avatar Jérome Perrin

pass _charset parameter by name, because the second positional argument is _subtype

Don't encode text/plain in base64, so that MUA can display it inline


git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@15893 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent cec164ff
...@@ -145,16 +145,16 @@ class Url(Coordinate, Base, UrlMixIn): ...@@ -145,16 +145,16 @@ class Url(Coordinate, Base, UrlMixIn):
subject=None, attachment_list=None): subject=None, attachment_list=None):
""" """
This method was previously named 'SendMail' and is used to send email This method was previously named 'SendMail' and is used to send email
attachment_list is a list of dictionnary wich has keys :
* attachment_list is a list of dictionnaries with those keys:
- name : name of the attachment, - name : name of the attachment,
- content: data of the attachment - content: data of the attachment
- mime_type: mime-type corresponding to the attachment - mime_type: mime-type corresponding to the attachment
""" """
# get the mailhost object # get the mailhost object
try: mailhost = getattr(self.getPortalObject(), 'MailHost', None)
mailhost=self.getPortalObject().MailHost if mailhost is None:
except: raise AttributeError, "Cannot find a MailHost object"
raise AttributeError, "Cannot find a Mail Host object"
else: else:
if from_url is None: if from_url is None:
from_url = self.getUrlString(None) from_url = self.getUrlString(None)
...@@ -194,13 +194,13 @@ class Url(Coordinate, Base, UrlMixIn): ...@@ -194,13 +194,13 @@ class Url(Coordinate, Base, UrlMixIn):
# attach it # attach it
if attachment['mime_type'] == 'text/plain': if attachment['mime_type'] == 'text/plain':
part = MIMEText(attachment['content'], 'utf-8') part = MIMEText(attachment['content'], _charset='utf-8')
else: else:
# encode non-plaintext attachment in base64 # encode non-plaintext attachment in base64
part = MIMEBase(*attachment['mime_type'].split('/', 1)) part = MIMEBase(*attachment['mime_type'].split('/', 1))
part.set_payload(attachment['content']) part.set_payload(attachment['content'])
Encoders.encode_base64(part) Encoders.encode_base64(part)
part.add_header('Content-Disposition', part.add_header('Content-Disposition',
'attachment; filename=%s' % attachment_name) 'attachment; filename=%s' % attachment_name)
message.attach(part) message.attach(part)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment