diff --git a/docs/meli.conf.5 b/docs/meli.conf.5 index cd9dafe9..b4ef18bd 100644 --- a/docs/meli.conf.5 +++ b/docs/meli.conf.5 @@ -199,11 +199,19 @@ property to each of them. .It Ic library_file_path Ar Path Use an arbitrary location of libnotmuch by specifying its full filesystem path. .Pq Em optional +.It Ic sent_mailbox_path Ar Path +Where to store sent e-mail in the filesystem. +Defaults to +.Ic root_mailbox Ns +\&. +.Pq Em optional .El Example: .Bd -literal [accounts.notmuch] +root_mailbox = "/path/to/notmuch/folder" format = "notmuch" +sent_mailbox_path = "/path/to/notmuch/folder/Sent/cur" #library_file_path = "/opt/homebrew/lib/libnotmuch.5.dylib" \&... [accounts.notmuch.mailboxes] diff --git a/melib/src/backends/notmuch.rs b/melib/src/backends/notmuch.rs index d82c8219..f49dc515 100644 --- a/melib/src/backends/notmuch.rs +++ b/melib/src/backends/notmuch.rs @@ -490,6 +490,18 @@ impl NotmuchDb { .set_kind(ErrorKind::Configuration)); } } + let save_messages_to = if let Some(sent_path) = s.extra.get("sent_mailbox_path") { + if !Path::new(&sent_path).exists() || !Path::new(&sent_path).is_dir() { + return Err(MeliError::new(format!( + "Notmuch `sent_mailbox_path` setting value `{}` for account {} does not exist or is not a directory.", + &sent_path, + s.name() + )).set_kind(ErrorKind::Configuration)); + } + Some(Path::new(&sent_path).to_path_buf()) + } else { + None + }; let account_hash = { let mut hasher = DefaultHasher::new(); @@ -509,7 +521,7 @@ impl NotmuchDb { account_name: account_name.clone(), account_hash, event_consumer: event_consumer.clone(), - save_messages_to: None, + save_messages_to: save_messages_to.clone(), }); Ok(Box::new(NotmuchDb { lib, @@ -519,7 +531,7 @@ impl NotmuchDb { account_name, account_hash, event_consumer, - save_messages_to: None, + save_messages_to, })) } @@ -571,6 +583,15 @@ impl NotmuchDb { .set_kind(ErrorKind::Configuration)); } } + if let Some(sent_path) = s.extra.remove("sent_mailbox_path") { + if !Path::new(&sent_path).exists() || !Path::new(&sent_path).is_dir() { + return Err(MeliError::new(format!( + "Notmuch `sent_mailbox_path` setting value `{}` for account {} does not exist or is not a directory.", + &sent_path, + s.name() + )).set_kind(ErrorKind::Configuration)); + } + } Ok(()) }