diff --git a/CHANGELOG.md b/CHANGELOG.md index 61704dc..ea221c8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -13,6 +13,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Added required IMAP option `imap-auth` and SMTP option `smtp-auth`. Possible values: `passwd`, `oauth2`. - Added OAuth 2.0 support for IMAP and SMTP. - Added passwords and OAuth 2.0 configuration via the wizard. +- Added `email-sending-save-copy` option to control whenever a copy of any sent email should be saved in the `sent` folder defined in `folder-aliases`. ### Changed diff --git a/src/domain/email/handlers.rs b/src/domain/email/handlers.rs index 09bf429..fa587f5 100644 --- a/src/domain/email/handlers.rs +++ b/src/domain/email/handlers.rs @@ -382,11 +382,13 @@ pub fn send( }; trace!("raw email: {:?}", raw_email); sender.send(raw_email.as_bytes())?; - backend.add_email( - &folder, - raw_email.as_bytes(), - &Flags::from_iter([Flag::Seen]), - )?; + if config.email_sending_save_copy { + backend.add_email( + &folder, + raw_email.as_bytes(), + &Flags::from_iter([Flag::Seen]), + )?; + } Ok(()) } diff --git a/src/domain/tpl/handlers.rs b/src/domain/tpl/handlers.rs index 3e2d78e..90b14cf 100644 --- a/src/domain/tpl/handlers.rs +++ b/src/domain/tpl/handlers.rs @@ -108,7 +108,9 @@ pub fn send( .some_pgp_encrypt_cmd(config.email_writing_encrypt_cmd.clone()), )?; sender.send(&email)?; - backend.add_email(folder, &email, &Flags::default())?; + if config.email_sending_save_copy { + backend.add_email(folder, &email, &Flags::default())?; + } printer.print("Template successfully sent!")?; Ok(()) } diff --git a/src/ui/editor.rs b/src/ui/editor.rs index 1808fd6..fd6334c 100644 --- a/src/ui/editor.rs +++ b/src/ui/editor.rs @@ -79,9 +79,11 @@ pub fn edit_tpl_with_editor( .some_pgp_encrypt_cmd(config.email_writing_encrypt_cmd.clone()), )?; sender.send(&email)?; - let sent_folder = config.sent_folder_alias()?; - printer.print_log(format!("Adding email to the {} folder…", sent_folder))?; - backend.add_email(&sent_folder, &email, &Flags::from_iter([Flag::Seen]))?; + if config.email_sending_save_copy { + let sent_folder = config.sent_folder_alias()?; + printer.print_log(format!("Adding email to the {} folder…", sent_folder))?; + backend.add_email(&sent_folder, &email, &Flags::from_iter([Flag::Seen]))?; + } remove_local_draft()?; printer.print("Done!")?; break;