IMAP client bindings for Rust.
Here is a basic example of using the client.
See the examples/
directory for more examples.
extern crate native_tls;
fn main() {
let domain = "imap.gmail.com";
let port = 993;
let socket_addr = (domain, port);
let ssl_connector = native_tls::TlsConnector::builder().unwrap().build().unwrap();
let mut imap_socket = Client::secure_connect(socket_addr, domain, &ssl_connector).unwrap();
imap_socket.login("username", "password").unwrap();
match imap_socket.capabilities() {
Ok(capabilities) => {
for capability in capabilities.iter() {
println!("{}", capability);
}
}
Err(e) => println!("Error parsing capabilities: {}", e),
};
match imap_socket.select("INBOX") {
Ok(mailbox) => {
println!("{}", mailbox);
}
Err(e) => println!("Error selecting INBOX: {}", e),
};
match imap_socket.fetch("2", "body[text]") {
Ok(messages) => {
for message in messages.iter() {
print!("{:?}", message);
}
}
Err(e) => println!("Error Fetching email 2: {}", e),
};
imap_socket.logout().unwrap();
}