mirror of
https://github.com/soywod/himalaya.git
synced 2024-11-25 04:20:22 +00:00
add send and sav subcommands
This commit is contained in:
parent
2b5be91af9
commit
f7ed99d55f
1 changed files with 37 additions and 0 deletions
37
src/main.rs
37
src/main.rs
|
@ -217,6 +217,17 @@ fn run() -> Result<()> {
|
|||
.arg(uid_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::with_name("template")
|
||||
.aliases(&["tpl", "t"])
|
||||
|
@ -471,6 +482,32 @@ fn run() -> Result<()> {
|
|||
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(())
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue