rust-pop3-client

Crates.iorust-pop3-client
lib.rsrust-pop3-client
version0.2.1
sourcesrc
created_at2023-02-21 09:32:08.345353
updated_at2023-02-21 09:35:45.85144
descriptionPOP3 client based on rustls
homepagehttps://github.com/falk-werner/rust-pop3-client
repositoryhttps://github.com/falk-werner/rust-pop3-client
max_upload_size
id790595
size44,024
Falk Werner (falk-werner)

documentation

README

rust-pop3-client

POP3 client for rust using rutls.

Features

  • provides all mandatory POP3 commands
  • provides most optional POP3 commands
    (APOP is not provided, since it is not used often)
  • allow to specify own certificates
    (a rustls::RootCertStore instance can be provided, if not system certificates will be used)

Depedency

Cargo.toml:

[dependencies]
rust-pop3-client = "0.2.1"

Example

use std::error::Error;
use std::io::{self, Write};

extern crate rust_pop3_client;

use rust_pop3_client::Pop3Connection;

fn read_value(prompt: &str) -> Result<String, Box<dyn Error>> {
    print!("{}: ", prompt);
    io::stdout().flush()?;
    let mut value = String::new();
    io::stdin().read_line(&mut value)?;
    Ok(String::from(value.trim()))
}

fn read_password(prompt: &str) -> Result<String, Box<dyn Error>> {
    print!("{}: ", prompt);
    io::stdout().flush()?;
    Ok(rpassword::read_password()?)
}

fn main() -> Result<(), Box<dyn Error>> {
    let host = read_value("host (e.g. pop.gmail.com)")?;
    let port = read_value("port (e.g. 995)")?.parse::<u16>()?;
    let user = read_value("user (e-mail address)")?;
    let password = read_password("password")?;

    let mut connection = Pop3Connection::new(&host, port)?;
    connection.login(&user, &password)?;

    println!("id\tsize");
    let infos = connection.list()?;
    for info in infos {
        println!("{}\t{}", info.message_id, info.message_size);
    }

    Ok(())
}

Similar projects

  • rust-pop3
    (Seems promising, but is based on an outdated version of OpenSSL.)

References

Commit count: 13

cargo fmt