diff options
author | Matthias Beyer <mail@beyermatthias.de> | 2020-01-05 19:20:10 +0100 |
---|---|---|
committer | Matthias Beyer <mail@beyermatthias.de> | 2020-01-05 19:20:10 +0100 |
commit | a3bda6a5a596b408937a401135e0dbbf693977c8 (patch) | |
tree | 77e21f05f7cd2c66a3608fd80009a0b7f62242cc | |
parent | 75163c49dd2cd1174d6301dd99db433960c9dfd4 (diff) |
Reimplement imag-mail frontend
Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
-rw-r--r-- | bin/domain/imag-mail/Cargo.toml | 2 | ||||
-rw-r--r-- | bin/domain/imag-mail/src/lib.rs | 238 | ||||
-rw-r--r-- | bin/domain/imag-mail/src/ui.rs | 92 | ||||
-rw-r--r-- | bin/domain/imag-mail/src/util.rs | 37 | ||||
-rw-r--r-- | doc/src/04020-module-mails.md | 357 |
5 files changed, 115 insertions, 611 deletions
diff --git a/bin/domain/imag-mail/Cargo.toml b/bin/domain/imag-mail/Cargo.toml index fd871089..ef543231 100644 --- a/bin/domain/imag-mail/Cargo.toml +++ b/bin/domain/imag-mail/Cargo.toml @@ -24,8 +24,6 @@ log = "0.4.6" failure = "0.1.5" resiter = "0.4" handlebars = "2" -walkdir = "2" -rayon = "1" libimagrt = { version = "0.10.0", path = "../../../lib/core/libimagrt" } libimagstore = { version = "0.10.0", path = "../../../lib/core/libimagstore" } diff --git a/bin/domain/imag-mail/src/lib.rs b/bin/domain/imag-mail/src/lib.rs index 10d6b850..d2ebf16f 100644 --- a/bin/domain/imag-mail/src/lib.rs +++ b/bin/domain/imag-mail/src/lib.rs @@ -40,8 +40,6 @@ extern crate clap; extern crate toml_query; extern crate resiter; extern crate handlebars; -extern crate walkdir; -extern crate rayon; extern crate libimagrt; extern crate libimagmail; @@ -51,27 +49,19 @@ extern crate libimagutil; extern crate libimagentryref; extern crate libimaginteraction; -use std::path::PathBuf; +use std::io::Write; use failure::Fallible as Result; use failure::err_msg; -use failure::Error; -use toml_query::read::TomlValueReadTypeExt; use clap::App; use resiter::AndThen; -use resiter::Filter; use resiter::IterInnerOkOrElse; -use resiter::Map; -use rayon::prelude::*; use libimagmail::store::MailStore; use libimagmail::mail::Mail; -use libimagentryref::util::get_ref_config; -use libimagentryref::reference::Config as RefConfig; +use libimagmail::notmuch::connection::NotmuchConnection; use libimagrt::runtime::Runtime; use libimagrt::application::ImagApplication; -use libimagutil::info_result::*; -use libimagstore::storeid::StoreIdIterator; use libimagstore::iter::get::StoreIdGetIteratorExtension; mod ui; @@ -85,12 +75,10 @@ pub enum ImagMail {} impl ImagApplication for ImagMail { fn run(rt: Runtime) -> Result<()> { match rt.cli().subcommand_name().ok_or_else(|| err_msg("No subcommand called"))? { - "scan" => scan(&rt), - "import-mail" => import_mail(&rt), - "list" => list(&rt), - "unread" => unread(&rt), - "mail-store" => mail_store(&rt), - other => { + "import" => import(&rt), + "list" => list(&rt), + "print-id" => print_id(&rt), + other => { debug!("Unknown command"); if rt.handle_unknown_subcommand("imag-mail", other, rt.cli())?.success() { Ok(()) @@ -118,172 +106,74 @@ impl ImagApplication for ImagMail { } } -fn scan(rt: &Runtime) -> Result<()> { - let collection_name = get_ref_collection_name(rt)?; - let refconfig = get_ref_config(rt, "imag-mail")?; - let scmd = rt.cli().subcommand_matches("scan").unwrap(); +fn import(rt: &Runtime) -> Result<()> { + let scmd = rt.cli().subcommand_matches("import").unwrap(); + let query = scmd.value_of("query").unwrap(); + let store = rt.store(); + let notmuch_path = crate::util::get_notmuch_database_path(rt)?; + let notmuch_connection = NotmuchConnection::open(notmuch_path)?; - /// Helper function to get an Iterator for all files from one PathBuf - fn walk_pathes(path: PathBuf) -> impl Iterator<Item = Result<PathBuf>> { - walkdir::WalkDir::new(path) - .follow_links(false) - .into_iter() - .filter_ok(|entry| entry.file_type().is_file()) - .map_err(Error::from) - .map_ok(|entry| entry.into_path()) - .inspect(|e| trace!("Processing = {:?}", e)) - } - - /// Helper function to process an iterator over Result<PathBuf> and create store entries for - /// each path in the iterator - fn process_iter(i: &mut dyn Iterator<Item = Result<PathBuf>>, rt: &Runtime, collection_name: &str, refconfig: &RefConfig) -> Result<()> { - let scmd = rt.cli().subcommand_matches("scan").unwrap(); - i.and_then_ok(|path| { - if scmd.is_present("ignore-existing-ids") { - rt.store().retrieve_mail_from_path(path, collection_name, refconfig, true) - } else { - rt.store().create_mail_from_path(path, collection_name, refconfig) - } - }) - .and_then_ok(|e| rt.report_touched(e.get_location()).map_err(Error::from)) - .collect::<Result<Vec<_>>>() - .map(|_| ()) - } - - let pathes = scmd.values_of("path") - .unwrap() // enforced by clap - .map(PathBuf::from) - .collect::<Vec<_>>(); + debug!("Importing mail with query = '{}'", query); - if scmd.is_present("scan-parallel") { - debug!("Fetching pathes in parallel"); - let mut i = pathes.into_par_iter() - .map(|path| walk_pathes(path).collect::<Result<_>>()) - .collect::<Result<Vec<PathBuf>>>()? - .into_iter() - .map(Ok); + let r = store + .with_connection(¬much_connection) + .import_with_query(query)? + .into_iter() + .map(|fle| rt.report_touched(fle.get_location())) + .collect::<Result<Vec<_>>>() + .map(|_| ()); - debug!("Processing pathes"); - process_iter(&mut i, rt, &collection_name, &refconfig) - } else { - debug!("Fetching pathes not in parallel"); - let mut i = pathes - .into_iter() - .map(walk_pathes) - .flatten(); - - debug!("Processing pathes"); - process_iter(&mut i, rt, &collection_name, &refconfig) - } -} - -fn import_mail(rt: &Runtime) -> Result<()> { - let collection_name = get_ref_collection_name(rt)?; - let refconfig = get_ref_config(rt, "imag-mail")?; - let scmd = rt.cli().subcommand_matches("import-mail").unwrap(); - let store = rt.store(); - - debug!(r#"Importing mail with - collection_name = {} - refconfig = {:?} - "#, collection_name, refconfig); - - scmd.values_of("path") - .unwrap() // enforced by clap - .map(PathBuf::from) - .map(|path| { - if scmd.is_present("ignore-existing-ids") { - store.retrieve_mail_from_path(path, &collection_name, &refconfig, true) - } else { - store.create_mail_from_path(path, &collection_name, &refconfig) - } - .map_info_str("Ok") - }) - .and_then_ok(|e| rt.report_touched(e.get_location()).map_err(Error::from)) - .collect::<Result<Vec<()>>>() - .map(|_| ()) + r } fn list(rt: &Runtime) -> Result<()> { - let refconfig = get_ref_config(rt, "imag-mail")?; - let scmd = rt.cli().subcommand_matches("list").unwrap(); // safe via clap - let list_format = util::get_mail_print_format("mail.list_format", rt, &scmd)?; - let mut out = rt.stdout(); - let mut i = 0; + let scmd = rt.cli().subcommand_matches("import").unwrap(); + let query = scmd.value_of("query").unwrap(); + let store = rt.store(); + let list_format = util::get_mail_print_format("mail.list_format", rt, &scmd)?; + let notmuch_path = crate::util::get_notmuch_database_path(rt)?; + let notmuch_connection = NotmuchConnection::open(notmuch_path)?; - if rt.ids_from_stdin() { - let iter = rt - .ids::<crate::ui::PathProvider>()? - .ok_or_else(|| err_msg("No ids supplied"))? - .into_iter() - .map(Ok); - StoreIdIterator::new(Box::new(iter)) - } else { - rt.store() - .all_mails()? - .into_storeid_iter() - } - .inspect(|id| debug!("Found: {:?}", id)) - .into_get_iter(rt.store()) - .map_inner_ok_or_else(|| err_msg("Did not find one entry")) - .and_then_ok(|m| { - crate::util::list_mail(&m, i, &refconfig, &list_format, &mut out)?; - rt.report_touched(m.get_location())?; - i += 1; - Ok(()) - }) - .collect::<Result<Vec<_>>>() - .map(|_| ()) -} - -fn unread(rt: &Runtime) -> Result<()> { - let refconfig = get_ref_config(rt, "imag-mail")?; - let scmd = rt.cli().subcommand_matches("unread").unwrap(); // safe via clap - let list_format = util::get_mail_print_format("mail.list_format", rt, &scmd)?; - let mut out = rt.stdout(); - let mut i = 0; - - if rt.ids_from_stdin() { - let iter = rt - .ids::<crate::ui::PathProvider>()? - .ok_or_else(|| err_msg("No ids supplied"))? - .into_iter() - .map(Ok); - - StoreIdIterator::new(Box::new(iter)) - } else { - rt.store().all_mails()?.into_storeid_iter() - } - .inspect(|id| debug!("Found: {:?}", id)) - .into_get_iter(rt.store()) - .map_inner_ok_or_else(|| err_msg("Did not find one entry")) - .and_then_ok(|m| { - if !m.is_seen(&refconfig)? { - crate::util::list_mail(&m, i, &refconfig, &list_format, &mut out)?; - rt.report_touched(m.get_location())?; - i += 1; - } - - Ok(()) - }) - .collect::<Result<Vec<_>>>() - .map(|_| ()) -} + let mut i = 0; + let mut out = rt.stdout(); + debug!("Importing mail with query = '{}'", query); + + let r = store + .with_connection(¬much_connection) + .query(query)? + .into_iter() + .map(|fle| { + let loaded = fle.load(¬much_connection)? + .ok_or_else(|| format_err!("Mail not found: {}", fle.get_location()))?; + + let parsed = loaded.parsed()?; + + let r = crate::util::list_mail(&parsed, i, &list_format, &mut out); + i += 1; // poor mans enumerate() + r.map(|_| fle) + }) + .and_then_ok(|fle| rt.report_touched(fle.get_location())) + .collect::<Result<Vec<_>>>() + .map(|_| ()); -fn mail_store(rt: &Runtime) -> Result<()> { - let _ = rt.cli().subcommand_matches("mail-store").unwrap(); - Err(format_err!("This feature is currently not implemented.")) + r } -fn get_ref_collection_name(rt: &Runtime) -> Result<String> { - let setting_name = "mail.ref_collection_name"; - - debug!("Getting configuration: {}", setting_name); - - rt.config() - .ok_or_else(|| format_err!("No configuration, cannot find collection name for mail collection"))? - .read_string(setting_name)? - .ok_or_else(|| format_err!("Setting missing: {}", setting_name)) +fn print_id(rt: &Runtime) -> Result<()> { + rt.ids::<crate::ui::PathProvider>()? + .ok_or_else(|| err_msg("No ids supplied"))? + .into_iter() + .map(Ok) + .into_get_iter(rt.store()) + .map_inner_ok_or_else(|| err_msg("Did not find one entry")) + .and_then_ok(|fle| { + let id = fle.get_cached_id()?; + writeln!(rt.stdout(), "{}", id)?; + Ok(fle) + }) + .and_then_ok(|fle| rt.report_touched(fle.get_location())) + .collect::<Result<Vec<_>>>() + .map(|_| ()) } diff --git a/bin/domain/imag-mail/src/ui.rs b/bin/domain/imag-mail/src/ui.rs index 324fabb4..eecb4020 100644 --- a/bin/domain/imag-mail/src/ui.rs +++ b/bin/domain/imag-mail/src/ui.rs @@ -28,98 +28,54 @@ use clap::{Arg, ArgMatches, App, SubCommand}; pub fn build_ui<'a>(app: App<'a, 'a>) -> App<'a, 'a> { app - .subcommand(SubCommand::with_name("import-mail") - .about("Import a mail (create a reference to it) (Maildir)") - .version("0.1") - .arg(Arg::with_name("ignore-existing-ids") - .long("ignore-existing") - .short("I") - .takes_value(false) - .required(false) - .help("Ignore errors that might occur when store entries exist already")) - .arg(Arg::with_name("path") - .index(1) - .takes_value(true) - .multiple(true) - .required(true) - .help("Path to the mail file(s) to import") - .value_name("PATH")) - ) + .arg(Arg::with_name("database_path") + .long("db") + .takes_value(true) + .required(false) + .value_name("PATH") + .help("The path to the notmuch database to use (defaults to value in config)")) - .subcommand(SubCommand::with_name("scan") - .about("Scan a directory for mails") + .subcommand(SubCommand::with_name("import") + .about("Import mails from notmuch") .version("0.1") - .arg(Arg::with_name("ignore-existing-ids") - .long("ignore-existing") - .short("I") - .takes_value(false) - .required(false) - .help("Ignore errors that might occur when store entries exist already")) - - .arg(Arg::with_name("scan-parallel") - .long("parallel") - .takes_value(false) - .required(false) - .multiple(false) - .help("Scan with multiple threads. Might be faster, but might slow down other tasks")) - - .arg(Arg::with_name("path") + .arg(Arg::with_name("query") .index(1) .takes_value(true) - .multiple(true) .required(true) - .validator(libimagutil::cli_validators::is_directory) - .value_name("DIR") - .help("Path to the directory containing mails")) + .value_name("QUERY") + .help("Imports mails from notmuch to imag, using a query to fetch mails to import")) ) .subcommand(SubCommand::with_name("list") - .about("List all stored references to mails") + .about("List mails in imag") .version("0.1") - - .arg(Arg::with_name("list-id") + .arg(Arg::with_name("query") .index(1) .takes_value(true) .required(false) - .multiple(true) - .help("The ids of the mails to list information for")) - - .arg(Arg::with_name("format") - .long("format") - .takes_value(true) - .required(false) - .multiple(false) - .help("The format to list the mails with")) + .value_name("QUERY") + .help("List Store IDs for mails in imag, using a query to ask notmuch for the mails")) ) - .subcommand(SubCommand::with_name("unread") - .about("Show unread mail") + .subcommand(SubCommand::with_name("print-id") + .about("Print id of mail(s)") .version("0.1") - - .arg(Arg::with_name("unread-read") - .long("read") - .short("r") - .takes_value(false) + .arg(Arg::with_name("ID") + .index(1) + .takes_value(true) + .multiple(true) .required(false) - .multiple(false) - .help("Print the textual content of the mail itself as well")) + .value_name("ID") + .help("Print ID of mail(s) identified by Store ID(s)")) ) - .subcommand(SubCommand::with_name("mail-store") - .about("Operations on (subsets of) all mails") - .version("0.1") - .subcommand(SubCommand::with_name("update-refs") - .about("Create references based on Message-IDs for all loaded mails") - .version("0.1")) - // TODO: We really should be able to filter here. - ) } pub struct PathProvider; impl IdPathProvider for PathProvider { fn get_ids(matches: &ArgMatches) -> Result<Option<Vec<StoreId>>> { - matches.values_of("list-id") + matches.values_of("ID") .map(|v| v .map(PathBuf::from) .map(|pb| pb.into_storeid()) diff --git a/bin/domain/imag-mail/src/util.rs b/bin/domain/imag-mail/src/util.rs index 7f116649..c17e8f4c 100644 --- a/bin/domain/imag-mail/src/util.rs +++ b/bin/domain/imag-mail/src/util.rs @@ -19,6 +19,7 @@ use std::collections::BTreeMap; use std::io::Write; +use std::path::PathBuf; use clap::ArgMatches; use failure::Error; @@ -27,10 +28,8 @@ use failure::err_msg; use handlebars::Handlebars; use toml_query::read::TomlValueReadTypeExt; -use libimagmail::mail::Mail; +use libimagmail::mail::ParsedMail; use libimagrt::runtime::Runtime; -use libimagstore::store::FileLockEntry; -use libimagentryref::reference::Config as RefConfig; pub fn get_mail_print_format(config_value_path: &'static str, rt: &Runtime, scmd: &ArgMatches) -> Result<Handlebars> { let fmt = match scmd.value_of("format").map(String::from) { @@ -53,27 +52,27 @@ pub fn get_mail_print_format(config_value_path: &'static str, rt: &Runtime, scmd Ok(hb) } -pub fn build_data_object_for_handlebars(i: usize, m: &FileLockEntry, refconfig: &RefConfig) -> Result<BTreeMap<&'static str, String>> { +pub fn build_data_object_for_handlebars<'a>(i: usize, m: &'a ParsedMail<'a>) -> Result<BTreeMap<&'static str, String>> { let mut data = BTreeMap::new(); data.insert("i", format!("{}", i)); - let id = match m.get_message_id(refconfig)? { - Some(f) => f.into(), + let id = match m.message_id()? { + Some(f) => f, None => "<no id>".to_owned(), }; - let from = match m.get_from(refconfig)? { + let from = match m.from()? { Some(f) => f, None => "<no from>".to_owned(), }; - let to = match m.get_to(refconfig)? { + let to = match m.to()? { Some(f) => f, None => "<no to>".to_owned(), }; - let subject = match m.get_subject(refconfig)? { + let subject = match m.subject()? { Some(f) => f, None => "<no subject>".to_owned(), }; @@ -86,10 +85,26 @@ pub fn build_data_object_for_handlebars(i: usize, m: &FileLockEntry, refconfig: Ok(data) } -pub fn list_mail(m: &FileLockEntry, i: usize, refconfig: &RefConfig, list_format: &Handlebars, out: &mut dyn Write) -> Result<()> { - let data = build_data_object_for_handlebars(i, m, refconfig)?; +pub fn list_mail<'a>(m: &'a ParsedMail<'a>, i: usize, list_format: &Handlebars, out: &mut dyn Write) -> Result<()> { + let data = build_data_object_for_handlebars(i, m)?; let s = list_format.render("format", &data)?; writeln!(out, "{}", s)?; Ok(()) } +pub fn get_notmuch_database_path(rt: &Runtime) -> Result<PathBuf> { + if let Some(pb) = rt.cli() + .value_of("database_path") + .map(String::from) + .map(PathBuf::from) + { + return Ok(pb) + } else { + rt.config() + .ok_or_else(|| err_msg("No configuration file"))? + .read_string("mail.notmuch_database") + .map_err(Error::from)? + .map(PathBuf::from) + .ok_or_else(|| format_err!("Configuration 'mail.notmuch_database' does not exist")) + } +} diff --git a/doc/src/04020-module-mails.md b/doc/src/04020-module-mails.md index 1786dfe9..75d70ccc 100644 --- a/doc/src/04020-module-mails.md +++ b/doc/src/04020-module-mails.md @@ -1,359 +1,4 @@ ## Mails {#sec:modules:mails} ---- - -**NOTE:** This is mostly a todo-list for the `imag-mail` command. Nothing shown -here is implemented. This "documentation-to-be" should be moved to -`imag-mail --help` eventually. -This list might be incomplete, details might be not possible to implement in the -way described or other dragons. - -**Target audience:** People who want to implement `imag-mail`. - ---- - -The Mails module implements a commandline email client. Emails can be written -(via `$EDITOR`) and viewed, also in threads. Emails can be crawled for creating -new contacts. - -A Text User Interface is not planned, but might be there at some point. - -The mail module implements a minimal Email client. It does not handle IMAP -syncing or SMTP things, it is just a _viewer_ for emails (a MUA). - -The goal of the initial implementation is only a CLI, not a TUI like mutt -offers, for example (but that might be implemented later). As this is an imag -module, it also creates references to mails inside the imag store which can be -used by other tools then (for example `imag-link` to link an entry with a mail - -or the imag entry representing that mail). - -So this module offers functionality to read (Maildir) mailboxes, search for and -list mails and mail-threads and reply to mails (by spawning the `$EDITOR`). - -Outgoing mails are pushed to a special directory and can later on be send via -`imag-mail` which calls a MTA (for example msmtp) and also creates store entries -for the outgoing mails. - - -### Configuration - -The following configuration variables are available for the imag-mail command: - -* `mail.defaultaccount`: The name of the default account to use if the - commandline parameters do not specify which account to use. The name must be - in the `mail.accounts` array. -* `mail.accounts`: - An array of account configuration. Each element in the array is a table of the - following key-value pairs: - * `name`: the name of the account. Names must be unique. Required. - * `outgoingbox`: Path to mailbox to use for outgoing email. Required. - * `draftbox`: Path to mailbox to use for outgoing email. Required. - * `sentbox`: Path to mailbox to use for sent email. Required. - ` `maildirroot`: Path to folder where all mailboxes for this account are - located. Required. - * `fetchcommand`: What commandline to invoke for fetching mails for this - account. Optional - if not used, the global `mail.fetchcommand` will be - used. - * `postfetchcommand`: What commandline to invoke after fetching mails for this - account. Optional - if not used, the global `mail.postfetchcommand` will be - used. - * `sendcommand`: What commandline to invoke for sending mails for this - account. Optional - if not used, the global `mail.sendcommand` will be used. - * `postsendcommand`: What commandline to invoke after sending mails for this - account. Optional - if not used, the global `mail.postsendcommand` will be - used. -* `mail.fetchcommand`: Command to use for fetching mail if no account-specific - command was specified - Available variables: - * `{{accountname}}` - name of the account to fetch mail for. - * `{{boxes}}` - a list of maildir paths to the boxes to fetch email for. - imag provides primitives to transform this array. - An example configuration for fetching with `offlineimap` might look like - this: `offlineimap -a {{accountname}} -f {{concatsep "," (replace "/home/user/mails/" "" boxes)}}` - to concatenate all boxes with a comma after removing a prefix. - For a complete list of transformation functions, the `--help` flag shall - be consulted. - For more complicated transformations a bash/ruby/python script might be - appropriate. -* `mail.postfetchcommand`: Command to use after fetching mail if no - account-specific command was specified - Available variables: Same as `mail.fetchcommand`. -* `mail.postsendcommand`: Command to use after sending mail if no - account-specific command was specified - Available variables: Same as `mail.sendcommand`. -* `mail.sendcommand`: Command to use for sending mail if no account-specific - command was specified - * `{{accountname}}` - name of the account to fetch mail for. - * `{{mailfile}}` - The path of the mail to send - - -### CLI - -The CLI of the imag-mail module is planned as follows: - -* imag mail - - -A, --account - Specify the "account" to use for the opperation by name. - If none is specified, the configuration is searched for a - default command. - -* imag mail track <path> [opts...] - Track a new mail, mail file passed as path - -* imag mail scan <path> [opts...] - Scan a maildir and track all untracked mails - - --refind - re-find messages. Loads all messages which are known to imag - and compares identifiers, to update the imag-internal cache if - a mail got moved. - Without this flag, a modified email file might be added to - the imag store again, even if there's another entry in the - imag store refering to the same file. - -* imag mail list <args...> - List mails in a given mailbox for a given account or the default account - - -S, --style - print messages in a certain style - Available: - - 'linewise' - - 'thread' - - -g, --grep - Filter by grepping for a pattern in body and subject - - -d, --daterange - Filter by date(range) - - -F, --filter - Filter by passed filter - - --thread - Print only messages from the same thread as the found ones - - --format=<fmt> - Format mails for showing. - --format always colorizes output (specify color in config) - except when using --no-pager or piping output. - - When --tree is passed, the format is applied to the - fragment _after_ the tree graphic. - - Default mode is 'default'. - - Modes: - - 'subject': <Subject> - - 'simple': <From>: <Subject> - - 'default': <Date> - <From>: <Subject> - - 'fmt:<fmt>' format with passed format - - Additional formats can be specified via the configuration - file. If a format has the same name as a predefined one, - the config overrides the predefined formats. - - --color - Colorize output (default). - --no-color - Do never colorize output. - -* imag mail show <args...> - Show mail(s) - either in pager or by printing them to stdout. - - Mails are specified by message id or imag entry - - --refind - If a imag entry is passed but the mail file is not there, - try to re-find it. - - --refind-in - Same as --refind, but a path to a Maildir or a tree of - Maildirs might be passed to narrow down search space. - - -C, --concat - Open all mails in one pager (by concatenating them) - instead of one pager per message. - - --pager - Use pager to show mails (default). - - --no-pager - Do not use pager to show mails. - - --multipager - Pass all mails as arguments to one pager call instead of - calling the pager on each mail individually (default). - Only possible with --pager. - - --no-multipager - Disable --multipager. - Only possible with --pager. - - --format=<fmt> - Format mails for showing. - --format always colorizes emails (specify color in config) - except when using --no-pager or piping output. - - Modes: - - 'simple': Remove headers, except - From, To, Cc, Subject, Date, - Message-Id/References/In-Reply-To - - 'simple-imag': Same as 'simple' but also show imag - entry id. - - 'print': Show everything - - 'full': Show everything and add imag entry id - - 'minimal': Remove headers, except From, To, Cc, Subject, Date, - - 'tiny': Remove headers, except From, To, Subject - - 'fmt:<fmt>' format with passed format - - Additional formats can be specified via the configuration - file. If a format has the same name as a predefined one, - the config overrides the predefined formats. - - --no-format - Disable all formatting (same as --pretty=print and - disabling color output). - - --color - Colorize output (default). - --no-color - Do never colorize output. - -* imag mail new <args...> - Craft a new mail and safe it in the <outgoing> folder - - Requires configuration: - * mail.accounts.[.draftbox] - * mail.accounts.[.outgoingbox] - - --outbox - Specify the outbox for where the new mail should be stored - in, if it is not given in the config (or to override it) - - --to - Specify to whom to send. - If the specified string does not contain a valid email - address, `imag contact find` is used to find the email - address (if not suppressed via --no-autofind). - Multiple allowed. - - --cc - Specify to whom to send in CC. - If the specified string does not contain a valid email - address, `imag contact find` is used to find the email - address (if not suppressed via --no-autofind). - Multiple allowed. - - --bcc - Specify to whom to send in BCC. - If the specified string does not contain a valid email - address, `imag contact find` is used to find the email - address (if not suppressed via --no-autofind). - Multiple allowed. - - --no-autofind - Do not automatically find contacts - with `imag contact find`. - - --fcc - Specify to store a copy of the mail somewhere. - Multiple allowed. - - --subject - Specify subject. - - --gpg-sign - Sign with gpg. - - --gpg-crypt - Crypt with gpg to all recipients. - - --no-track - Do not track new mailfile with imag. - - -D, --draft - Do not safe in "outgoing" box but rather in "draft" box. - -* imag mail compose <args...> - Same as 'new'. - -* imag mail fetch <args...> - Fetch emails - - Requires configuration: - * mail.fetchcommand or mail.accounts[.fetchcommand] - * mail.postfetchcommand or mail.accounts[.postfetchcommand] (optional) - - --all - Fetch for all accounts - --boxes - Fetch only some boxes (does not work with --all) - -* imag mail send <args...> - Send emails from the outgoing folder, also move them to 'sent' boxes - - Requires configuration: - * mail.accounts.[.outgoingbox] - * mail.accounts.[.sentbox] - * mail.sendcommand or mail.accounts[.sendcommand] - * mail.postsendcommand or mail.accounts[.postsendcommand] (optional) - - --outbox - Specify the outbox for where the mails that are about to - be send are stored in, if it is not given in the config - (or to override it). - - --sentbox - Specify the sentbox for where the sent mails should be - moved after sending them, if it is not given in the config - (or to override it). - - --no-move-sent - Do not move mail to the "sent" folder after sending it. - - --confirm - Confirm each mail before sending (default). - - --no-confirm - Do not confirm each mail before sending. - - --no-track - Do not track mailfile with imag. Does only work if `imag - mail new` was invoked with `--no-track` (so that the mail - is not tracked already). - -* imag mail mv <src mail> <dstbox> - Move a mail to another mailbox - - --thread - Move the complete thread of emails belonging to the - specified mail. - - --no-track - Do not track new mailfile with imag. Does not work if - mailfile is already tracked with imag. - -* imag mail find <args...> - Search for a mail (by header field (msgid, from, to, cc, subject, date, - date-range), body, ...) - - --msgid - --no-msgid - --from - --no-from - --to - --no-to - --cc - --no-cc - --subject - --no-subject - --date - --no-date - --body - --no-body - --daterange - Toggle where to look at - - --print-entryid - Print imag entry id when finding mail - --no-print-entryid - Do not print imag entry id when finding mail (default). - - --print=<what> - What to print for the found mails. - Valid values: - - msgid - - subject - - from - - cc - - to - - date - - filepath (default) - -* imag mail reply <args...> - Reply to an email. - - Requires configuration: mail.accounts[.outgoingbox] - - Specify the mail to reply to by msgid, filepath or imag entry id. - - --add-to - --add-cc - --add-bcc - Add another recipient. Multiple allowed. - - --no-track - Do not track new mailfile with imag. - -### Format specifiers - -The `imag-mail` command supports formatting output automatically and via -predefined formats in the configuration file or by passing formatting -specifications via CLI. - -The available formatting variables are: - -* `H`: The complete message header as key-value-table -* `subject`: The subject of the message -* `date`: The date field of the message -* `body`: The body of the message -* `from`: The sender of the message -* `to`: The address of the receipient of message -* `fancyfromto`: The address of the sender of the message, or, if the sender was - you, the receipient (prefixed with `F:` or `T:` respecively). - -<!-- more might be defined --> +Frontend for imag mail handing, using notmuch as a mail database backend. |