Browse Source

Email_fetcher : Add support for IMAP unencrypted connection

Guénaël Muller 7 years ago
parent
commit
0cebea15d8

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

@@ -221,6 +221,7 @@ email.reply.imap.port = 993
221 221
 email.reply.imap.user = your_imap_user
222 222
 email.reply.imap.password = your_imap_password
223 223
 email.reply.imap.folder = INBOX
224
+email.reply.imap.ssl = true
224 225
 # Token for communication between mail fetcher and tracim controller
225 226
 email.reply.token = mysecuretoken
226 227
 # Delay in seconds between each check

+ 3 - 0
tracim/tracim/config/app_cfg.py View File

@@ -379,6 +379,9 @@ class CFG(object):
379 379
         self.EMAIL_REPLY_TOKEN = tg.config.get(
380 380
             'email.reply.token',
381 381
         )
382
+        self.EMAIL_REPLY_IMAP_SSL = asbool(tg.config.get(
383
+            'email.reply.imap.ssl',
384
+        ))
382 385
 
383 386
         self.TRACKER_JS_PATH = tg.config.get(
384 387
             'js_tracker_path',

+ 1 - 0
tracim/tracim/lib/daemons.py View File

@@ -171,6 +171,7 @@ class MailFetcherDaemon(Daemon):
171 171
             port=cfg.EMAIL_REPLY_IMAP_PORT,
172 172
             user=cfg.EMAIL_REPLY_IMAP_USER,
173 173
             password=cfg.EMAIL_REPLY_IMAP_PASSWORD,
174
+            ssl=cfg.EMAIL_REPLY_IMAP_SSL,
174 175
             folder=cfg.EMAIL_REPLY_IMAP_FOLDER,
175 176
             delay=cfg.EMAIL_REPLY_CHECK_HEARTBEAT,
176 177
             # FIXME - G.M - 2017-11-15 - proper tracim url formatting

+ 8 - 2
tracim/tracim/lib/email_fetcher.py View File

@@ -176,6 +176,7 @@ class MailFetcher(object):
176 176
                  port: str,
177 177
                  user: str,
178 178
                  password: str,
179
+                 ssl: bool,
179 180
                  folder: str,
180 181
                  delay: int,
181 182
                  endpoint: str,
@@ -189,6 +190,7 @@ class MailFetcher(object):
189 190
         :param port: imap connection port
190 191
         :param user: user login of mailbox
191 192
         :param password: user password of mailbox
193
+        :param ssl: use imap over ssl connection
192 194
         :param folder: mail folder where new mail are fetched
193 195
         :param delay: seconds to wait before fetching new mail again
194 196
         :param endpoint: tracim http endpoint where decoded mail are send.
@@ -199,6 +201,7 @@ class MailFetcher(object):
199 201
         self.port = port
200 202
         self.user = user
201 203
         self.password = password
204
+        self.ssl = ssl
202 205
         self.folder = folder
203 206
         self.delay = delay
204 207
         self.endpoint = endpoint
@@ -225,11 +228,14 @@ class MailFetcher(object):
225 228
         # Are old connexion properly close this way ?
226 229
         if self._connection:
227 230
             self._disconnect()
228
-        # TODO - G.M - 2017-11-15 Support unencrypted connection ?
229 231
         # TODO - G.M - 2017-11-23 Support for predefined SSLContext ?
230 232
         # without ssl_context param, tracim use default security configuration
231 233
         # which is great in most case.
232
-        self._connection = imaplib.IMAP4_SSL(self.host, self.port)
234
+        if self.ssl:
235
+            self._connection = imaplib.IMAP4_SSL(self.host, self.port)
236
+        else:
237
+            self._connection = imaplib.IMAP4(self.host, self.port)
238
+
233 239
         try:
234 240
             self._connection.login(self.user, self.password)
235 241
         except Exception as e: