plug option email-sending-save-copy

This commit is contained in:
Clément DOUIN 2023-05-19 16:00:13 +02:00
parent 5da1148dc9
commit 5a2d842cbe
No known key found for this signature in database
GPG key ID: 353E4A18EE0FAB72
4 changed files with 16 additions and 9 deletions

View file

@ -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

View file

@ -382,11 +382,13 @@ pub fn send<P: Printer>(
};
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(())
}

View file

@ -108,7 +108,9 @@ pub fn send<P: Printer>(
.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(())
}

View file

@ -79,9 +79,11 @@ pub fn edit_tpl_with_editor<P: Printer>(
.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;