示例#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
示例#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,
                search=self.searching,
                mailbox=self
            )
            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)
        return conn