No description
Find a file
2017-10-30 20:57:06 -04:00
examples Swap openssl for native-tls (#43) 2017-10-01 19:53:03 -04:00
src Swap openssl for native-tls (#43) 2017-10-01 19:53:03 -04:00
.gitignore Initial Commit 2015-04-15 16:23:58 -04:00
.travis.yml Add OSX build on Travis CI 2017-10-04 20:13:31 -04:00
appveyor.yml Swap openssl for native-tls (#43) 2017-10-01 19:53:03 -04:00
Cargo.toml Bumping version from 0.5.0 -> 0.6.0 2017-10-01 19:54:00 -04:00
LICENSE-APACHE Relicense as Apache 2.0 / MIT 2016-01-10 17:34:19 -05:00
LICENSE-MIT Relicense as Apache 2.0 / MIT 2016-01-10 17:34:19 -05:00
README.md Update readme to use native_tls 2017-10-30 20:57:06 -04:00

rust-imap

IMAP Client for Rust

Number of Crate Downloads Crate Version Crate License Build Status Build Status Coverage Status

Documentation

Usage

Here is a basic example of using the client. See the examples directory for more examples.

extern crate imap;
extern crate native_tls;

use native_tls::TlsConnector;
use imap::client::Client;

// To connect to the gmail IMAP server with this you will need to allow unsecure apps access.
// See: https://support.google.com/accounts/answer/6010255?hl=en
// Look at the gmail_oauth2.rs example on how to connect to a gmail server securely.
fn main() {
    let domain = "imap.gmail.com";
    let port = 993;
    let socket_addr = (domain, port);
    let ssl_connector = 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.capability() {
        Ok(capabilities) => {
            for capability in capabilities.iter() {
                println!("{}", capability);
            }
        }
        Err(e) => println!("Error parsing capability: {}", 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(lines) => {
            for line in lines.iter() {
                print!("{}", line);
            }
        }
        Err(e) => println!("Error Fetching email 2: {}", e),
    };

    imap_socket.logout().unwrap();
}

License

Licensed under either of

Contribution

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.