Browse Source

Replace email.notification.from config

Bastien Sevajol (Algoo) 7 years ago
parent
commit
4c8eea3b31

+ 2 - 1
README.md View File

@@ -318,7 +318,8 @@ The reset password related parameters are the follwoing ones :
318 318
 The main parameters for notifications are the following ones:
319 319
 
320 320
     email.notification.activated = true
321
-    email.notification.from = Tracim Notification <tracim@tmycompany.com>
321
+    email.notification.from.email = noreply@trac.im
322
+    email.notification.from.default_label = Tracim Notification
322 323
     email.notification.smtp.server = smtp.mycompany.com
323 324
     email.notification.smtp.port = 25
324 325
     email.notification.smtp.user = username

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

@@ -176,7 +176,8 @@ website.base_url = http://127.0.0.1:8080
176 176
 website.server_name = 127.0.0.1
177 177
     
178 178
 email.notification.activated = False
179
-email.notification.from = Tracim Notification <noreply@trac.im>
179
+email.notification.from.email = noreply@trac.im
180
+email.notification.from.default_label = Tracim Notifications
180 181
 email.notification.content_update.template.html = ./tracim/templates/mail/content_update_body_html.mak
181 182
 email.notification.content_update.template.text = ./tracim/templates/mail/content_update_body_text.mak
182 183
 email.notification.created_account.template.html = ./tracim/templates/mail/created_account_body_html.mak

+ 10 - 1
tracim/tracim/config/app_cfg.py View File

@@ -202,8 +202,17 @@ class CFG(object):
202 202
         self.WEBSITE_SUBTITLE = tg.config.get('website.home.subtitle', '')
203 203
         self.WEBSITE_HOME_BELOW_LOGIN_FORM = tg.config.get('website.home.below_login_form', '')
204 204
 
205
+        if tg.config.get('email.notification.from'):
206
+            raise Exception(
207
+                'email.notification.from configuration is deprecated. '
208
+                'Use instead email.notification.from.email and '
209
+                'email.notification.from.default_label.'
210
+            )
205 211
 
206
-        self.EMAIL_NOTIFICATION_FROM = tg.config.get('email.notification.from')
212
+        self.EMAIL_NOTIFICATION_FROM_EMAIL = \
213
+            tg.config.get('email.notification.from.email')
214
+        self.EMAIL_NOTIFICATION_FROM_DEFAULT_LABEL = \
215
+            tg.config.get('email.notification.from.default_label')
207 216
         self.EMAIL_NOTIFICATION_CONTENT_UPDATE_TEMPLATE_HTML = tg.config.get('email.notification.content_update.template.html')
208 217
         self.EMAIL_NOTIFICATION_CONTENT_UPDATE_TEMPLATE_TEXT = tg.config.get('email.notification.content_update.template.text')
209 218
         self.EMAIL_NOTIFICATION_CREATED_ACCOUNT_TEMPLATE_HTML = tg.config.get(

+ 4 - 1
tracim/tracim/lib/email.py View File

@@ -103,7 +103,10 @@ class EmailManager(object):
103 103
             )
104 104
         message = MIMEMultipart('alternative')
105 105
         message['Subject'] = subject
106
-        message['From'] = self._global_config.EMAIL_NOTIFICATION_FROM
106
+        message['From'] = '{0} <{1}>'.format(
107
+            self._global_config.EMAIL_NOTIFICATION_FROM_DEFAULT_LABEL,
108
+            self._global_config.EMAIL_NOTIFICATION_FROM_EMAIL,
109
+        )
107 110
         message['To'] = user.email
108 111
 
109 112
         text_template_file_path = self._global_config.EMAIL_NOTIFICATION_CREATED_ACCOUNT_TEMPLATE_TEXT  # nopep8

+ 4 - 1
tracim/tracim/lib/notifications.py View File

@@ -233,7 +233,10 @@ class EmailNotifier(object):
233 233
 
234 234
             message = MIMEMultipart('alternative')
235 235
             message['Subject'] = subject
236
-            message['From'] = self._global_config.EMAIL_NOTIFICATION_FROM
236
+            message['From'] = '{0} <{1}>'.format(
237
+                self._global_config.EMAIL_NOTIFICATION_FROM_DEFAULT_LABEL,
238
+                self._global_config.EMAIL_NOTIFICATION_FROM_EMAIL,
239
+            )
237 240
             message['To'] = to_addr
238 241
 
239 242
             body_text = self._build_email_body(self._global_config.EMAIL_NOTIFICATION_CONTENT_UPDATE_TEMPLATE_TEXT, role, content, user)