Login | Register
My pages Projects Community openCollabNet

Discussions > Commits > svn commit: r142 - trunk/repoguard/src/repoguard/modules/smtp_client.py

repoguard
Discussion topic

Hide all messages in topic

All messages in topic

svn commit: r142 - trunk/repoguard/src/repoguard/modules/smtp_client.py

Author schlauch
Full name Tobias Schlauch
Date 2012-10-08 09:51:22 PDT
Message Author: schlauch
Date: 2012-10-08 09:51:21-0700
New Revision: 142

Modified:
   trunk/repoguard/src/​repoguard/modules/sm​tp_client.py

Log:
Added missing newline to correctly send message body.

Added optional configuration option 'local_hostname' which can be used if the automatic resolution of the smtplib does not work.

Modified: trunk/repoguard/src/​repoguard/modules/sm​tp_client.py
Url: http://repoguard.tig​ris.org/source/brows​e/repoguard/trunk/re​poguard/src/repoguar​d/modules/smtp_clien​t.py?view=diff&p​athrev=142&r1=14​1&r2=142
====================​====================​====================​==================
--- trunk/repoguard/src/​repoguard/modules/sm​tp_client.py (original)
+++ trunk/repoguard/src/​repoguard/modules/sm​tp_client.py 2012-10-08 09:51:21-0700
@@ -18,13 +18,14 @@
         "Subject: %s\n"
         "MIME-Version: 1.0\n"
         "Content-Type: text/plain; charset=%s\n"
- "Content-Transfer-Encoding: 8bit\n%s")
+ "Content-Transfer-Encoding: 8bit\n\n%s")
            
- def __init__(self, server_name="localhost", port=0, credentials=None, debug_level=0):
+ def __init__(self, server_name="localhost", port=0, credentials=None, debug_level=0, local_hostname=None):
         self._server_name = server_name
         self._port = port
         self._credentials = credentials
         self._debug_level = debug_level
+ self._local_hostname = local_hostname
     
     def send_mail(self, sender, receivers, subject, message):
         """
@@ -42,7 +43,7 @@
             smtp_client.quit()
         
     def _initialize_mail_client(self):
- smtp_client = smtplib.SMTP(self._server_name, self._port)
+ smtp_client = smtplib.SMTP(self._server_name, self._port, self._local_hostname)
         smtp_client.set_debu​glevel(self._debug_l​evel)
         if self._credentials:
             user, password = self._credentials
Messages per page: