summaryrefslogtreecommitdiff
path: root/alot/account.py
diff options
context:
space:
mode:
Diffstat (limited to 'alot/account.py')
-rw-r--r--alot/account.py22
1 files changed, 14 insertions, 8 deletions
diff --git a/alot/account.py b/alot/account.py
index 71398c22..218e33cf 100644
--- a/alot/account.py
+++ b/alot/account.py
@@ -95,16 +95,22 @@ class Account(object):
:type mail: :class:`email.message.Message` or str
:param tags: if given, add the mail to the notmuch index and tag it
:type tags: list of str
+ :returns: True iff mail was successfully stored
+ :rtype: bool
"""
- mbx.lock()
- if isinstance(mbx, mailbox.Maildir):
- msg = mailbox.MaildirMessage(mail)
- msg.set_flags('S')
+ if not isinstance(mbx, mailbox.Mailbox):
+ return False
else:
- msg = mailbox.Message(mail)
- message_id = mbx.add(mail)
- mbx.flush()
- mbx.unlock()
+ mbx.lock()
+ if isinstance(mbx, mailbox.Maildir):
+ msg = mailbox.MaildirMessage(mail)
+ msg.set_flags('S')
+ else:
+ msg = mailbox.Message(mail)
+ mbx.add(msg)
+ mbx.flush()
+ mbx.unlock()
+ return True
if isinstance(mbx, mailbox.Maildir) and tags != None:
# this is a dirty hack to get the path to the newly added file