No description
Find a file
Jon Gjengset b07216ca7a Make IDLE API be more straightforward (#41)
In particular, the API for `IdleHandle` now reflects that it is only
really meant for single-use. It mutably borrows the `Client`, so once
`wait` returns there isn't really a good reason to keep the `IdleHandle`
around (because you'll likely want to issue some other commands).

There is something to be said for being able to operate on the IDLE
stream, but we'll leave that for later.

This also avoids some unfortunate unavoidable panics when the connection
fails while the client is IDLEing.
2017-09-29 22:37:15 -04:00
examples rustfmt the codebase (#36) 2017-07-10 21:38:13 -04:00
src Make IDLE API be more straightforward (#41) 2017-09-29 22:37:15 -04:00
.gitignore Initial Commit 2015-04-15 16:23:58 -04:00
.travis.yml Use docs.rs for documentation (#40) 2017-09-28 17:19:54 -04:00
appveyor.yml Add a build for windows using appveyor (#37) 2017-07-12 17:05:32 -04:00
Cargo.toml Add more info to Cargo.toml (#42) 2017-09-29 22:26:49 -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 Use docs.rs for documentation (#40) 2017-09-28 17:19:54 -04:00

rust-imap

IMAP Client for Rust

Build Status Build Status crates.io 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 openssl;

use openssl::ssl::{SslConnectorBuilder, SslMethod};
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 = SslConnectorBuilder::new(SslMethod::tls()).unwrap().build();
    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.