Last active
December 3, 2019 03:42
-
-
Save sanxiyn/15493ca613a837721efc5a89fa11f952 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use std::error::Error; | |
use std::fs; | |
use argparse::{ArgumentParser, Store}; | |
fn main() -> Result<(), Box<Error>> { | |
let mut mailbox_name = String::new(); | |
{ | |
let mut parser = ArgumentParser::new(); | |
parser.refer(&mut mailbox_name) | |
.add_argument("label", Store, ""); | |
parser.parse_args_or_exit(); | |
} | |
let domain = "imap.gmail.com"; | |
let username = fs::read_to_string("username")?; | |
let password = fs::read_to_string("password")?; | |
let tls = native_tls::TlsConnector::new()?; | |
let client = imap::connect((domain, 993), domain, &tls)?; | |
let mut session = client.login(username, password) | |
.map_err(|(error, _)| error)?; | |
let mailbox = session.select(&mailbox_name)?; | |
println!("{}: {}", mailbox_name, mailbox.exists); | |
Ok(()) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment