Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def next(self):
self.curnum += 1
try:
return IMAPMailbox(self.conn,self.mailboxlist[self.curnum].split()[2])
except IndexError:
raise StopIteration
@type fromCache: C{bool}
@return: C{IMAPClient}
"""
assert isinstance(account, Mail.IMAPAccount)
if not fromCache:
return IMAPClient(self._clientView, account, self._mailWorker)
imapInstances = self._clientInstances.get("IMAP")
if account.itsUUID in imapInstances:
return imapInstances.get(account.itsUUID)
i = IMAPClient(self._clientView, account, self._mailWorker)
imapInstances[account.itsUUID] = i
return i
@param account: A IMAPAccount
@type account: C{IMAPAccount}
@param fromCache: Boolean flag indicating whether the
c{IMAPClient} instance should come from
the cache.
@type fromCache: C{bool}
@return: C{IMAPClient}
"""
assert isinstance(account, Mail.IMAPAccount)
if not fromCache:
return IMAPClient(self._clientView, account, self._mailWorker)
imapInstances = self._clientInstances.get("IMAP")
if account.itsUUID in imapInstances:
return imapInstances.get(account.itsUUID)
i = IMAPClient(self._clientView, account, self._mailWorker)
imapInstances[account.itsUUID] = i
return i
def downloadIMAPMail():
accountKind = Mail.MailParcel.getIMAPAccountKind()
for account in Query.KindQuery().run([accountKind]):
imap.IMAPDownloader(account).getMail()
internal, human and machine. anyways you may sit this param to None.
@param fmt: specifying the format, this has been set to "H"
@param remain: this parameter specifies the size of the remaining
data so make it 0 to handle all of the data.
"""
self.name = name
StrField.__init__(self, name, default, fmt, remain)
class IMAPRes(Packet):
"""
class for handling imap responses
@attention: it inherets Packet from Scapy library
"""
name = "imap"
fields_desc = [IMAPField("response", "", "H")]
class IMAPReq(Packet):
"""
class for handling imap requests
@attention: it inherets Packet from Scapy library
"""
name = "imap"
fields_desc = [IMAPField("request", "", "H")]
bind_layers(TCP, IMAPReq, dport=143)
bind_layers(TCP, IMAPRes, sport=143)
class IMAPRes(Packet):
"""
class for handling imap responses
@attention: it inherets Packet from Scapy library
"""
name = "imap"
fields_desc = [IMAPField("response", "", "H")]
class IMAPReq(Packet):
"""
class for handling imap requests
@attention: it inherets Packet from Scapy library
"""
name = "imap"
fields_desc = [IMAPField("request", "", "H")]
bind_layers(TCP, IMAPReq, dport=143)
bind_layers(TCP, IMAPRes, sport=143)
username = self.config.get('username', None)
if not username:
raise ConfigurationError("'username' option is required")
password = self.config.get('password', None)
if not password:
raise ConfigurationError("'password' option is required")
port = self.config.get('port', None)
ssl = self.config.get('ssl', False)
query = self.config.get('query', 'all')
if not query in ['all', 'unseen', 'undeleted']:
raise ConfigurationError("Unknown query: %s" % query)
mailboxes = self.config.get('inboxes', ['INBOX'])
self.base_url = self.config.get('base_url', None)
self.rules = self.config['rules']
client = ImapClient(host, username, password, port, ssl)
self.msg_list = getattr(client, query)()
else:
raise ConfigurationError("Backend '%s' is not supported" %\
self.config['backend'])
def next(self):
self.curnum += 1
try:
typ, data = self.imap.uid('fetch',self.numbers[self.curnum],'(RFC822)')
if data == None:
return StopIteration
except IndexError:
raise StopIteration
return IMAPMail(self.conn,self.mailbox,self.seen,self.numbers[self.curnum],data[0][1])
def __iter__(self):
return IMAPMailIterator(self.conn,self.mailbox)
def __iter__(self):
return IMAPMailboxIterator(self)