mirror of
https://github.com/soywod/himalaya.git
synced 2024-07-08 18:45:13 +00:00
add send and sav subcommands
This commit is contained in:
parent
2b5be91af9
commit
f7ed99d55f
37
src/main.rs
37
src/main.rs
|
@ -217,6 +217,17 @@ fn run() -> Result<()> {
|
||||||
.arg(uid_arg())
|
.arg(uid_arg())
|
||||||
.arg(mailbox_arg()),
|
.arg(mailbox_arg()),
|
||||||
)
|
)
|
||||||
|
.subcommand(
|
||||||
|
SubCommand::with_name("send")
|
||||||
|
.about("Sends a raw message")
|
||||||
|
.arg(Arg::with_name("message").raw(true)),
|
||||||
|
)
|
||||||
|
.subcommand(
|
||||||
|
SubCommand::with_name("save")
|
||||||
|
.about("Saves a raw message in the given mailbox")
|
||||||
|
.arg(mailbox_arg())
|
||||||
|
.arg(Arg::with_name("message").raw(true)),
|
||||||
|
)
|
||||||
.subcommand(
|
.subcommand(
|
||||||
SubCommand::with_name("template")
|
SubCommand::with_name("template")
|
||||||
.aliases(&["tpl", "t"])
|
.aliases(&["tpl", "t"])
|
||||||
|
@ -471,6 +482,32 @@ fn run() -> Result<()> {
|
||||||
imap_conn.logout();
|
imap_conn.logout();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if let Some(matches) = matches.subcommand_matches("send") {
|
||||||
|
let config = Config::new_from_file()?;
|
||||||
|
let account = config.find_account_by_name(account_name)?;
|
||||||
|
let mut imap_conn = ImapConnector::new(&account)?;
|
||||||
|
|
||||||
|
let msg = matches.value_of("message").unwrap();
|
||||||
|
let msg = Msg::from(msg.to_string());
|
||||||
|
|
||||||
|
smtp::send(&account, &msg.to_sendable_msg()?)?;
|
||||||
|
imap_conn.append_msg("Sent", &msg.to_vec()?)?;
|
||||||
|
imap_conn.logout();
|
||||||
|
}
|
||||||
|
|
||||||
|
if let Some(matches) = matches.subcommand_matches("save") {
|
||||||
|
let config = Config::new_from_file()?;
|
||||||
|
let account = config.find_account_by_name(account_name)?;
|
||||||
|
let mut imap_conn = ImapConnector::new(&account)?;
|
||||||
|
|
||||||
|
let mbox = matches.value_of("mailbox").unwrap();
|
||||||
|
let msg = matches.value_of("message").unwrap();
|
||||||
|
let msg = Msg::from(msg.to_string());
|
||||||
|
|
||||||
|
imap_conn.append_msg(mbox, &msg.to_vec()?)?;
|
||||||
|
imap_conn.logout();
|
||||||
|
}
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue