Browse Source

Fix Encoding issue when sending mail

tr4ck3ur 2 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

@@ -42,18 +42,22 @@ def mailer_tasks(config):
42 42
         # Prepare Plain Text Message :
43 43
         Mail_template = Template(filename='jm2l/templates/mail_plain.mako')
44 44
         mail_plain = Mail_template.render(request=request, User=StaffUser, Contact=Contact, action="Tasks")
45
-        print mail_plain
45
+        att_plain = Attachment( data=mail_plain,
46
+            content_type="text/plain; charset='utf-8'", transfer_encoding='quoted-printable')
46 47
         # Prepare HTML Message :
47 48
         Mail_template = Template(filename='jm2l/templates/mail_html.mako')
48 49
         mail_html = Mail_template.render(request=request, User=StaffUser, Contact=Contact, action="Tasks")
49
-        print mail_html
50
+        att_html = Attachment( data=mail_html,
51
+            content_type="text/html; charset='utf-8'", transfer_encoding='quoted-printable')
52
+        
50 53
         # Prepare Message
51 54
         message = Message(subject="[JM2L] Rappel des Tâches pour les JM2L",
52 55
                           sender="contact@jm2l.linux-azur.org",
53 56
                           recipients=[StaffUser.mail],
54
-                          body=mail_plain, html=mail_html)
57
+                          body=att_plain, html=att_html)
55 58
     
56 59
         message.add_bcc("spam@style-python.fr")
60
+        
57 61
         mailer.send(message)
58 62
 
59 63
 def main(global_config, **settings):