Skip to content

Commit

Permalink
feature: compose: allow not storing the sent emails
Browse files Browse the repository at this point in the history
I'm using lieer/gmi to send email, and it has the builtin assumption
that no new messages will be added to the maildir. See gauteh/lieer#54
  • Loading branch information
schopin-pro committed Oct 24, 2023
1 parent d400746 commit a5d6d87
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
12 changes: 9 additions & 3 deletions dodo/compose.py
Original file line number Diff line number Diff line change
Expand Up @@ -480,12 +480,18 @@ def run(self) -> None:
self.panel.status = f'<i style="color:{settings.theme["fg_bad"]}">timed out</i>'

def _store_sent_email(eml: email.message.EmailMessage, account):
# save to sent folder
m = mailbox.MaildirMessage(str(eml))
m.set_flags('S')
# Pick the right directory
if isinstance(settings.sent_dir, dict):
sent_dir = settings.sent_dir[account]
else:
sent_dir = settings.sent_dir

# None means we should discard the email, presumably because it's already
# handled by whatever mechanism sends it in the first place
if sent_dir is None:
return

m = mailbox.MaildirMessage(str(eml))
m.set_flags('S')
key = mailbox.Maildir(sent_dir).add(m)
# print(f'add: {key}')
4 changes: 4 additions & 0 deletions dodo/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,10 @@
:func:`~dodo.settings.sync_mail_command`. This setting can be given either
as a string to use one global sent directory, or as a dictionary mapping
account names in :func:`~dodo.settings.smtp_accounts` to their own sent dirs.
A value of None, either standalone or as one of the dict value, can be used to
indicate the email should be discarded. This can be useful if the sendmail
command already has a mechanism for that feature.
"""

editor_command = "xterm -e vim '{file}'"
Expand Down

0 comments on commit a5d6d87

Please sign in to comment.