Edgewall Software

Changes between Initial Version and Version 1 of Ticket #12419, comment 4


Ignore:
Timestamp:
Mar 25, 2016, 11:54:57 PM (8 years ago)
Author:
Christian Boos

Legend:

Unmodified
Added
Removed
Modified
  • Ticket #12419, comment 4

    initial v1  
    77
    88Ok, what about:
    9 {{{#!diff
    10 diff --git a/trac/notification/mail.py b/trac/notification/mail.py
    11 index 2bccf87..ea24022 100644
    12 --- a/trac/notification/mail.py
    13 +++ b/trac/notification/mail.py
    14 @@ -432,6 +432,8 @@ class SmtpEmailSender(Component):
    15      use_tls = BoolOption('notification', 'use_tls', 'false',
    16          """Use SSL/TLS to send notifications over SMTP.""")
    17 
    18 +    local_hostname = 'localhost'
    19 +
    20      def send(self, from_addr, recipients, message):
    21          # Ensure the message complies with RFC2822: use CRLF line endings
    22          message = fix_eol(message, CRLF)
    23 @@ -439,7 +441,9 @@ class SmtpEmailSender(Component):
    24          self.log.info("Sending notification through SMTP at %s:%d to %s",
    25                        self.smtp_server, self.smtp_port, recipients)
    26          try:
    27 -            server = smtplib.SMTP(self.smtp_server, self.smtp_port, 'localhost')
    28 +            server = smtplib.SMTP(self.smtp_server, self.smtp_port,
    29 +                                  self.local_hostname)
    30 +            self.local_hostname = server.local_hostname
    31          except smtplib.socket.error as e:
    32              raise ConfigurationError(
    33                  tag_("SMTP server connection error (%(error)s). Please "
    34 }}}
     9(scratch that...)
    3510
    3611`smtplib.SMTP.local_hostname` isn't part of the "public" API, however it looks stable enough to me (present from at least from Python 2.4.4 to current head).