19 releases (8 breaking)

0.8.1 Apr 30, 2018
0.7.0 Feb 9, 2018
0.6.0 Oct 1, 2017
0.3.3 Jul 13, 2017
0.0.3 Jun 15, 2015

#15 in Email

Download history 6/week @ 2018-06-08 81/week @ 2018-06-15 33/week @ 2018-06-22 95/week @ 2018-06-29 16/week @ 2018-07-06 20/week @ 2018-07-13 82/week @ 2018-07-20 50/week @ 2018-07-27 65/week @ 2018-08-03 224/week @ 2018-08-10 5/week @ 2018-08-17 35/week @ 2018-08-24 23/week @ 2018-08-31

108 downloads per month
Used in 2 crates

Apache-2.0/MIT

65KB
1.5K SLoC

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.

Dependencies

~3.5MB
~58K SLoC