Browse Source

Fix Encoding issue when sending mail

master
tr4ck3ur des JM2L 9 years ago
parent
commit
2b7534c804
1 changed files with 7 additions and 3 deletions
  1. +7
    -3
      jm2l/__init__.py

+ 7
- 3
jm2l/__init__.py View File

@@ -42,18 +42,22 @@ def mailer_tasks(config):
# Prepare Plain Text Message : # Prepare Plain Text Message :
Mail_template = Template(filename='jm2l/templates/mail_plain.mako') Mail_template = Template(filename='jm2l/templates/mail_plain.mako')
mail_plain = Mail_template.render(request=request, User=StaffUser, Contact=Contact, action="Tasks") mail_plain = Mail_template.render(request=request, User=StaffUser, Contact=Contact, action="Tasks")
print mail_plain
att_plain = Attachment( data=mail_plain,
content_type="text/plain; charset='utf-8'", transfer_encoding='quoted-printable')
# Prepare HTML Message : # Prepare HTML Message :
Mail_template = Template(filename='jm2l/templates/mail_html.mako') Mail_template = Template(filename='jm2l/templates/mail_html.mako')
mail_html = Mail_template.render(request=request, User=StaffUser, Contact=Contact, action="Tasks") mail_html = Mail_template.render(request=request, User=StaffUser, Contact=Contact, action="Tasks")
print mail_html
att_html = Attachment( data=mail_html,
content_type="text/html; charset='utf-8'", transfer_encoding='quoted-printable')
# Prepare Message # Prepare Message
message = Message(subject="[JM2L] Rappel des Tâches pour les JM2L", message = Message(subject="[JM2L] Rappel des Tâches pour les JM2L",
sender="contact@jm2l.linux-azur.org", sender="contact@jm2l.linux-azur.org",
recipients=[StaffUser.mail], recipients=[StaffUser.mail],
body=mail_plain, html=mail_html)
body=att_plain, html=att_html)
message.add_bcc("spam@style-python.fr") message.add_bcc("spam@style-python.fr")
mailer.send(message) mailer.send(message)


def main(global_config, **settings): def main(global_config, **settings):


Loading…
Cancel
Save