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
laarmen committed Oct 24, 2023
1 parent 2f3fb2b commit e7c14f5
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
11 changes: 7 additions & 4 deletions dodo/compose.py
Original file line number Diff line number Diff line change
Expand Up @@ -468,14 +468,17 @@ def run(self) -> None:
sendmail.wait(30)
if sendmail.returncode == 0:
# save to sent folder
m = mailbox.MaildirMessage(str(eml))
m.set_flags('S')
if isinstance(settings.sent_dir, dict):
sent_dir = settings.sent_dir[account]
else:
sent_dir = settings.sent_dir
key = mailbox.Maildir(sent_dir).add(m)
# print(f'add: {key}')
# 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 not None:
m = mailbox.MaildirMessage(str(eml))
m.set_flags('S')
key = mailbox.Maildir(sent_dir).add(m)
# print(f'add: {key}')

subprocess.run(['notmuch', 'new', '--no-hooks'])

Expand Down
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 e7c14f5

Please sign in to comment.