9 | | (scratch that...) |
| 9 | {{{#!diff |
| 10 | diff --git a/trac/notification/mail.py b/trac/notification/mail.py |
| 11 | index 2bccf87..9606052 100644 |
| 12 | --- a/trac/notification/mail.py |
| 13 | +++ b/trac/notification/mail.py |
| 14 | @@ -61,6 +61,7 @@ EMAIL_LOOKALIKE_PATTERN = ( |
| 15 | |
| 16 | _mime_encoding_re = re.compile(r'=\?[^?]+\?[bq]\?[^?]+\?=', re.IGNORECASE) |
| 17 | |
| 18 | +local_hostname = None |
| 19 | |
| 20 | |
| 21 | def create_charset(mime_encoding): |
| 22 | @@ -433,13 +434,16 @@ class SmtpEmailSender(Component): |
| 23 | """Use SSL/TLS to send notifications over SMTP.""") |
| 24 | |
| 25 | def send(self, from_addr, recipients, message): |
| 26 | + global local_hostname |
| 27 | # Ensure the message complies with RFC2822: use CRLF line endings |
| 28 | message = fix_eol(message, CRLF) |
| 29 | |
| 30 | self.log.info("Sending notification through SMTP at %s:%d to %s", |
| 31 | self.smtp_server, self.smtp_port, recipients) |
| 32 | try: |
| 33 | - server = smtplib.SMTP(self.smtp_server, self.smtp_port, 'localhost') |
| 34 | + server = smtplib.SMTP(self.smtp_server, self.smtp_port, |
| 35 | + local_hostname) |
| 36 | + local_hostname = server.local_hostname |
| 37 | except smtplib.socket.error as e: |
| 38 | raise ConfigurationError( |
| 39 | tag_("SMTP server connection error (%(error)s). Please " |
| 40 | }}} |
| 41 | (caching it on the component doesn't help much for the tests, since the reuse rate is very low) |