No description
Find a file
Jon Gjengset 73c8d0ddc2
Move README example into src/lib.rs
This way it'll be run as a doctest and we'll know if it breaks (again).

Fixes #67.
2018-04-03 13:01:59 -04:00
examples rustfmt 2018-04-03 13:01:35 -04:00
src Move README example into src/lib.rs 2018-04-03 13:01:59 -04:00
.gitignore Initial Commit 2015-04-15 16:23:58 -04:00
.travis.yml Workaround for travis-ci/travis-ci#9061 2018-01-22 19:55:38 -05:00
appveyor.yml Swap openssl for native-tls (#43) 2017-10-01 19:53:03 -04:00
Cargo.toml Bump for new changes 2018-02-09 11:25:18 -05: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 Move README example into src/lib.rs 2018-04-03 13:01:59 -04:00
README.tpl Move README example into src/lib.rs 2018-04-03 13:01:59 -04:00

imap

Crate Version Documentation Crate License Build Status Build Status Coverage Status

IMAP client bindings for Rust.

Usage

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

extern crate native_tls;

// 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 `examples/gmail_oauth2.rs` for how to connect to gmail securely.
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();
}

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.