diff options
author | Patrick Totzke <patricktotzke@gmail.com> | 2011-12-25 13:12:33 +0000 |
---|---|---|
committer | Patrick Totzke <patricktotzke@gmail.com> | 2011-12-25 16:42:32 +0000 |
commit | ce1cdbc0bb069d06a3acc7dbe3767dce47711c39 (patch) | |
tree | 503af881d372143d5a6f36f13c03a0a10cea7f8d /alot/account.py | |
parent | 8e658c063de9af0657a1e95498167976dcb44cb6 (diff) |
return values for Account.store_mail
this also fixes the issue of not using the created msg object,
cf. issue #198
Diffstat (limited to 'alot/account.py')
-rw-r--r-- | alot/account.py | 22 |
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 |