Ticket #2503: announcerplugin-internationalized-chars-and-enable-tls.diff
| File announcerplugin-internationalized-chars-and-enable-tls.diff, 2.4 kB (added by leorochael, 5 months ago) |
|---|
-
./distributors/email_distributor.py
old new 12 12 from email.MIMEMultipart import MIMEMultipart 13 13 from email.MIMEText import MIMEText 14 14 from email.Utils import formatdate 15 from email.header import Header 15 16 import time, Queue, threading, smtplib 16 17 17 18 class DeliveryThread(threading.Thread): … … 223 224 output = formatter.format(transport, event.realm, format, event) 224 225 subject = formatter.format_subject(transport, event.realm, format, event) 225 226 227 charset = self.env.config.get('trac', 'default_charset') or 'utf-8' 226 228 alternate_format = formatter.get_format_alternative(transport, event.realm, format) 227 229 if alternate_format: 228 230 alternate_output = formatter.format(transport, event.realm, alternate_format, event) … … 245 247 rootMessage['X-Announcement-%s' % key.capitalize()] = str(provided_headers[key]) 246 248 247 249 rootMessage['Date'] = formatdate() 248 rootMessage['Subject'] = subject250 rootMessage['Subject'] = Header(subject, charset) 249 251 rootMessage['From'] = self.smtp_from 250 252 if to: 251 253 rootMessage['To'] = '"%s"'%(to) … … 261 263 parentMessage = rootMessage 262 264 263 265 if alternate_output: 264 msgText = MIMEText(alternate_output, 'html' in alternate_format and 'html' or 'plain' )266 msgText = MIMEText(alternate_output, 'html' in alternate_format and 'html' or 'plain', charset) 265 267 parentMessage.attach(msgText) 266 268 267 msgText = MIMEText(output, 'html' in format and 'html' or 'plain' )269 msgText = MIMEText(output, 'html' in format and 'html' or 'plain', charset) 268 270 parentMessage.attach(msgText) 269 271 270 272 start = time.time() … … 281 283 def _transmit(self, smtpfrom, addresses, message): 282 284 smtp = smtplib.SMTP() 283 285 smtp.connect(self.smtp_server) 286 if self.use_tls: 287 smtp.ehlo() 288 smtp.starttls() 284 289 if self.smtp_user: 285 290 smtp.login(self.smtp_user, self.smtp_password) 286 291 smtp.sendmail(smtpfrom, addresses, message)
