Browse Source

WIP reply-to/references header in notif mail to allow reply mail

Guénaël Muller 7 years ago
parent
commit
54dac658c6

+ 2 - 0
tracim/development.ini.base View File

190
 # notifications generated by a user or another one
190
 # notifications generated by a user or another one
191
 email.notification.from.email = noreply+{user_id}@trac.im
191
 email.notification.from.email = noreply+{user_id}@trac.im
192
 email.notification.from.default_label = Tracim Notifications
192
 email.notification.from.default_label = Tracim Notifications
193
+email.notification.reply_to.email = reply+{content_id}@trac.im
194
+email.notification.references.email = thread+{content_id}@trac.im
193
 email.notification.content_update.template.html = %(here)s/tracim/templates/mail/content_update_body_html.mak
195
 email.notification.content_update.template.html = %(here)s/tracim/templates/mail/content_update_body_html.mak
194
 email.notification.content_update.template.text = %(here)s/tracim/templates/mail/content_update_body_text.mak
196
 email.notification.content_update.template.text = %(here)s/tracim/templates/mail/content_update_body_text.mak
195
 email.notification.created_account.template.html = %(here)s/tracim/templates/mail/created_account_body_html.mak
197
 email.notification.created_account.template.html = %(here)s/tracim/templates/mail/created_account_body_html.mak

+ 6 - 0
tracim/tracim/config/app_cfg.py View File

299
         self.EMAIL_NOTIFICATION_FROM_DEFAULT_LABEL = tg.config.get(
299
         self.EMAIL_NOTIFICATION_FROM_DEFAULT_LABEL = tg.config.get(
300
             'email.notification.from.default_label'
300
             'email.notification.from.default_label'
301
         )
301
         )
302
+        self.EMAIL_NOTIFICATION_REPLY_TO_EMAIL = tg.config.get(
303
+            'email.notification.reply_to.email',
304
+        )
305
+        self.EMAIL_NOTIFICATION_REFERENCES_EMAIL = tg.config.get(
306
+            'email.notification.references.email'
307
+        )
302
         self.EMAIL_NOTIFICATION_CONTENT_UPDATE_TEMPLATE_HTML = tg.config.get(
308
         self.EMAIL_NOTIFICATION_CONTENT_UPDATE_TEMPLATE_HTML = tg.config.get(
303
             'email.notification.content_update.template.html',
309
             'email.notification.content_update.template.html',
304
         )
310
         )

+ 10 - 2
tracim/tracim/lib/notifications.py View File

5
 from email.header import Header
5
 from email.header import Header
6
 from email.mime.multipart import MIMEMultipart
6
 from email.mime.multipart import MIMEMultipart
7
 from email.mime.text import MIMEText
7
 from email.mime.text import MIMEText
8
+from email.utils import formataddr
8
 
9
 
9
 from lxml.html.diff import htmldiff
10
 from lxml.html.diff import htmldiff
10
 
11
 
270
         for role in notifiable_roles:
271
         for role in notifiable_roles:
271
             logger.info(self, 'Sending email to {}'.format(role.user.email))
272
             logger.info(self, 'Sending email to {}'.format(role.user.email))
272
             to_addr = '{name} <{email}>'.format(name=role.user.display_name, email=role.user.email)
273
             to_addr = '{name} <{email}>'.format(name=role.user.display_name, email=role.user.email)
273
-
274
+            replyto_addr = self._global_config.EMAIL_NOTIFICATION_REPLY_TO_EMAIL.replace( # nopep8
275
+                '{content_id}',str(content.content_id)
276
+            )
277
+            reference_addr = self._global_config.EMAIL_NOTIFICATION_REFERENCES_EMAIL.replace( #nopep8
278
+                '{content_id}',str(content.content_id)
279
+             )
274
             #
280
             #
275
             #  INFO - D.A. - 2014-11-06
281
             #  INFO - D.A. - 2014-11-06
276
             # We do not use .format() here because the subject defined in the .ini file
282
             # We do not use .format() here because the subject defined in the .ini file
287
             message['Subject'] = subject
293
             message['Subject'] = subject
288
             message['From'] = self._get_sender(user)
294
             message['From'] = self._get_sender(user)
289
             message['To'] = to_addr
295
             message['To'] = to_addr
290
-
296
+            message['Reply-to'] = formataddr(('',replyto_addr))
297
+            message['References'] = formataddr(('',reference_addr))
298
+            # TODO: add correct header to allow reply
291
             body_text = self._build_email_body(self._global_config.EMAIL_NOTIFICATION_CONTENT_UPDATE_TEMPLATE_TEXT, role, content, user)
299
             body_text = self._build_email_body(self._global_config.EMAIL_NOTIFICATION_CONTENT_UPDATE_TEMPLATE_TEXT, role, content, user)
292
 
300
 
293
 
301