python3
inpos 2016-05-31 10:01:40 +03:00
commit 44182ddd45
2 changed files with 10 additions and 9 deletions

View File

@ -60,16 +60,17 @@ class SmtpFileStore(object):
class MailDirStore(object): class MailDirStore(object):
def __init__(self): def __init__(self):
from serpent.imap import mailbox import mailbox
self.mbox = mailbox self.mbox = mailbox
def deliver(self, user, message): def deliver(self, user, message):
mdir = os.path.join(conf.app_dir, conf.maildir_user_path % user) mdir = os.path.join(conf.app_dir, conf.maildir_user_path % user)
if not os.path.exists(mdir): if not os.path.exists(mdir):
os.makedirs(mdir) os.makedirs(mdir)
inbox = os.path.join(mdir, 'INBOX') inbox = os.path.join(mdir, 'INBOX')
mailbox = self.mbox.IMAPMailbox(inbox) mailbox = self.mbox.Maildir(inbox)
msg = self.mbox.MaildirMessage(message)
try: try:
mailbox.addMessage(message, [IMAP_FLAGS['RECENT']]) mailbox.add(msg, [])
return True return True
except: except:
raise raise

View File

@ -3,12 +3,12 @@ MSG_ACTIVE = 0
MSG_FROZEN = 1 MSG_FROZEN = 1
IMAP_FLAGS = { IMAP_FLAGS = {
'SEEN': '\\Seen', 'S': '\\Seen',
'FLAGGED': '\\Flagged', 'F': '\\Flagged',
'ANSWERED': '\\Answered', 'P': '\\Passed',
'RECENT': '\\Recent', 'R': '\\Replied',
'DELETED': '\\Deleted', 'T': '\\Trashed',
'DRAFT': '\\Draft' 'D': '\\Draft'
} }
IMAP_HDELIM = '.' IMAP_HDELIM = '.'
IMAP_ACC_CONN_NUM = '...ConnectionNumber...' IMAP_ACC_CONN_NUM = '...ConnectionNumber...'