Exemple #1
0
 def get_connection(self):
     if not self.uri:
         return None
     elif self.type == 'imap':
         conn = ImapTransport(
             self.location,
             port=self.port if self.port else None,
             ssl=self.use_ssl
         )
         conn.connect(self.username, self.password)
     elif self.type == 'pop3':
         conn = Pop3Transport(
             self.location,
             port=self.port if self.port else None,
             ssl=self.use_ssl
         )
         conn.connect(self.username, self.password)
     elif self.type == 'maildir':
         conn = MaildirTransport(self.location)
     elif self.type == 'mbox':
         conn = MboxTransport(self.location)
     elif self.type == 'babyl':
         conn = BabylTransport(self.location)
     elif self.type == 'mh':
         conn = MHTransport(self.location)
     elif self.type == 'mmdf':
         conn = MMDFTransport(self.location)
     return conn
Exemple #2
0
    def get_connection(self):
        """Returns the transport instance for this mailbox.

        These will always be instances of
        `django_mailbox.transports.base.EmailTransport`.

        """
        if not self.uri:
            return None
        elif self.type == 'imap':
            conn = ImapTransport(
                self.location,
                port=self.port if self.port else None,
                ssl=self.use_ssl,
                tls=self.use_tls,
                archive=self.archive,
                folder=self.folder
            )
            conn.connect(self.username, self.password)
        elif self.type == 'gmail':
            conn = GmailImapTransport(
                self.location,
                port=self.port if self.port else None,
                ssl=True,
                archive=self.archive
            )
            conn.connect(self.username, self.password)
        elif self.type == 'pop3':
            conn = Pop3Transport(
                self.location,
                port=self.port if self.port else None,
                ssl=self.use_ssl
            )
            conn.connect(self.username, self.password)
        elif self.type == 'maildir':
            conn = MaildirTransport(self.location)
        elif self.type == 'mbox':
            conn = MboxTransport(self.location)
        elif self.type == 'babyl':
            conn = BabylTransport(self.location)
        elif self.type == 'mh':
            conn = MHTransport(self.location)
        elif self.type == 'mmdf':
            conn = MMDFTransport(self.location)
        elif self.type == 'gmailapi':
            conn = GmailAPITransport()
            conn.connect(self.username, self.password, self._protocol_info.path) #user email, user id, watch address

        return conn
Exemple #3
0
    def get_connection(self):
        """Returns the transport instance for this mailbox.

        These will always be instances of
        `django_mailbox.transports.base.EmailTransport`.

        """
        if not self.uri:
            return None
        elif self.type == 'imap':
            conn = ImapTransport(self.location,
                                 port=self.port if self.port else None,
                                 ssl=self.use_ssl,
                                 tls=self.use_tls,
                                 archive=self.archive,
                                 folder=self.folder)
            conn.connect(self.username, self.password)
        elif self.type == 'gmail':
            conn = GmailImapTransport(self.location,
                                      port=self.port if self.port else None,
                                      ssl=True,
                                      archive=self.archive)
            conn.connect(self.username, self.password)
        elif self.type == 'pop3':
            conn = Pop3Transport(self.location,
                                 port=self.port if self.port else None,
                                 ssl=self.use_ssl)
            conn.connect(self.username, self.password)
        elif self.type == 'maildir':
            conn = MaildirTransport(self.location)
        elif self.type == 'mbox':
            conn = MboxTransport(self.location)
        elif self.type == 'babyl':
            conn = BabylTransport(self.location)
        elif self.type == 'mh':
            conn = MHTransport(self.location)
        elif self.type == 'mmdf':
            conn = MMDFTransport(self.location)
        elif self.type == 'gmailapi':
            conn = GmailAPITransport()
            conn.connect(
                self.username, self.password,
                self._protocol_info.path)  #user email, user id, watch address

        return conn