POP3 client for Rust



POP3 Client for Rust

This client has SSL support. SSL is configured using an SSLContext that is passed into the connect method of a POP3Stream. If no SSL support is wanted just pass in None. The library rust-openssl is used to support SSL for this project.

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



extern crate pop3;
extern crate openssl;

use openssl::ssl::{SslConnector, SslMethod};
use pop3::POP3Stream;
use pop3::POP3Result::{POP3Stat, POP3List, POP3Message, POP3Err};

fn main() {
	let mut gmail_socket = match POP3Stream::connect(("pop.gmail.com", 995), Some(SslConnector::builder(SslMethod::tls()).unwrap().build()),"pop.gmail.com") {
        Ok(s) => s,
        Err(e) => panic!("{}", e)

    let res = gmail_socket.login("username", "password");
    match res {
        POP3Err => println!("Err logging in"),
        _ => (),

    let stat = gmail_socket.stat();
    match stat {
    	POP3Stat {num_email,
				  mailbox_size} => println!("num_email: {},  mailbox_size:{}", num_email, mailbox_size),
		_ => println!("Err for stat"),

    let list_all = gmail_socket.list(None);
    match list_all {
        POP3List {emails_metadata} => {
            for i in emails_metadata.iter() {
                println!("message_id: {},  message_size: {}", i.message_id, i.message_size);
        _ => println!("Err for list_all"),

    let message_25 = gmail_socket.retr(25);
    match message_25 {
        POP3Message{raw} => {
            for i in raw.iter() {
                println!("{}", i);
        _ => println!("Error for message_25"),




  • implement a function to send UIDL command

    implement a function to send UIDL command

    Since this library seems to lack the implementation of UIDL command. So I wrote functions that send the UIDL command and that parse the response from server, based on rfc1939. Please check my code.

    Sorry for my poor english. Thank you.

    opened by hebiyan 3
  • Failed logon does not give error.

    Failed logon does not give error.

    A failed logon to a "Microsoft Exchange POP3" server does not give a error, and sets the authenticated flag.

    Wireshark summary: S: -ERR Logon failure: unknown user name or bad password.

    opened by Morindhal 2
  • Refactor Travis CI build

    Refactor Travis CI build

    Building and testing are now done using the regular cargo tool. Test coverage is only uploaded on linux stable. Use cargo tarpaulin for uploading test coverage to coveralls

    opened by mattnenterprise 1
  • Two small cleanups

    Two small cleanups

    Someone was asking about the &'static str argument type on irc. Seems better to copy the referenced str data if a persistent copy is needed. The (host, port) tuple change seems easier to read than the format!() macro.

    opened by rillian 1
  • Updated to native_tls, rustc 2021 edition, and created an example directory.

    Updated to native_tls, rustc 2021 edition, and created an example directory.

    I simply replaced a few bits of code swapping out the openssl bits to the native_tls alternative, addressing #16. I also moved the example to the example directory enabling the use of (addressing #13 ): cargo run --example gmail

    Please confirm I did this right! I'll fix any issues with this as soon as possible.

    opened by 641i130 0
  • POP3 retrieval errors after failure

    POP3 retrieval errors after failure

    Hi, I just tried to retrieve some mails in a loop, knowing that message #44 is not formatted correctly according to RFC (Spam message contains un-encoded binary data) and so, must run into error:


    for i in 43..49 {
            let message = pop3.retr(i);
            let _eml = match message {
                POP3Message { raw: _ } => println!("{} ->  OK", i),
                _ => {  println!("{} -> ERR", i)


    43 ->  OK
    44 -> ERR
    45 -> ERR
    46 -> ERR
    47 -> ERR
    48 -> ERR

    Omitting message #44 in this loop by adding if i == 44 { continue } before pop3.retr results in correct output:

    43 ->  OK
    45 ->  OK
    46 ->  OK
    47 ->  OK
    48 ->  OK

    Any ideas what´s going wrong here? Did I miss something?

    opened by ttcc-gh 0
  • Relicense under dual MIT/Apache-2.0

    Relicense under dual MIT/Apache-2.0

    This issue was automatically generated. Feel free to close without ceremony if you do not agree with re-licensing or if it is not possible for other reasons. Respond to @cmr with any questions or concerns, or pop over to #rust-offtopic on IRC to discuss.

    You're receiving this because someone (perhaps the project maintainer) published a crates.io package with the license as "MIT" xor "Apache-2.0" and the repository field pointing here.

    TL;DR the Rust ecosystem is largely Apache-2.0. Being available under that license is good for interoperation. The MIT license as an add-on can be nice for GPLv2 projects to use your code.


    The MIT license requires reproducing countless copies of the same copyright header with different names in the copyright field, for every MIT library in use. The Apache license does not have this drawback. However, this is not the primary motivation for me creating these issues. The Apache license also has protections from patent trolls and an explicit contribution licensing clause. However, the Apache license is incompatible with GPLv2. This is why Rust is dual-licensed as MIT/Apache (the "primary" license being Apache, MIT only for GPLv2 compat), and doing so would be wise for this project. This also makes this crate suitable for inclusion and unrestricted sharing in the Rust standard distribution and other projects using dual MIT/Apache, such as my personal ulterior motive, the Robigalia project.

    Some ask, "Does this really apply to binary redistributions? Does MIT really require reproducing the whole thing?" I'm not a lawyer, and I can't give legal advice, but some Google Android apps include open source attributions using this interpretation. Others also agree with it. But, again, the copyright notice redistribution is not the primary motivation for the dual-licensing. It's stronger protections to licensees and better interoperation with the wider Rust ecosystem.


    To do this, get explicit approval from each contributor of copyrightable work (as not all contributions qualify for copyright, due to not being a "creative work", e.g. a typo fix) and then add the following to your README:

    ## License
    Licensed under either of
     * Apache License, Version 2.0, ([LICENSE-APACHE](LICENSE-APACHE) or http://www.apache.org/licenses/LICENSE-2.0)
     * MIT license ([LICENSE-MIT](LICENSE-MIT) or http://opensource.org/licenses/MIT)
    at your option.
    ### 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.

    and in your license headers, if you have them, use the following boilerplate (based on that used in Rust):

    // Copyright 2016 rust-pop3 Developers
    // Licensed under the Apache License, Version 2.0, <LICENSE-APACHE or
    // http://apache.org/licenses/LICENSE-2.0> or the MIT license <LICENSE-MIT or
    // http://opensource.org/licenses/MIT>, at your option. This file may not be
    // copied, modified, or distributed except according to those terms.

    It's commonly asked whether license headers are required. I'm not comfortable making an official recommendation either way, but the Apache license recommends it in their appendix on how to use the license.

    Be sure to add the relevant LICENSE-{MIT,APACHE} files. You can copy these from the Rust repo for a plain-text version.

    And don't forget to update the license metadata in your Cargo.toml to:

    license = "MIT OR Apache-2.0"

    I'll be going through projects which agree to be relicensed and have approval by the necessary contributors and doing this changes, so feel free to leave the heavy lifting to me!

    Contributor checkoff

    To agree to relicensing, comment with :

    I license past and future contributions under the dual MIT/Apache-2.0 license, allowing licensees to chose either at their option.

    Or, if you're a contributor, you can check the box in this repo next to your name. My scripts will pick this exact phrase up and check your checkbox, but I'll come through and manually review this issue later as well.

    • [ ] @Wooowe
    • [x] @hebiyan
    • [x] @mattnenterprise
    opened by emberian 2
Matt McCoy
Matt McCoy
FTP client for Rust

rust-ftp FTP client for Rust Documentation rust-ftp Installation Usage License Contribution Development environment Installation FTPS support is achie

Matt McCoy 155 Nov 12, 2022
NNTP client for Rust

rust-nntp NNTP Client for Rust Usage extern crate nntp; use nntp::{Article, NNTPStream}; fn main() { let mut nntp_stream = match NNTPStream::connec

Matt McCoy 13 Jan 22, 2022
A STOMP client in Rust. Compatible with RabbitMQ, ActiveMQ.

stomp-rs stomp-rs provides a full STOMP 1.2 client implementation for the Rust programming language. This allows programs written in Rust to interact

Zack Slayton 84 Dec 4, 2022
Rust client for NATS, the cloud native messaging system.

A Rust client for the NATS messaging system. Status Motivation Rust may be the most interesting new language the NATS ecosystem has seen. We believe t

NATS - The Cloud Native Messaging System 651 Jan 3, 2023
rqbit - bittorrent client in Rust

rqbit - bittorrent client in Rust

Igor Katson 177 Jan 2, 2023
Simple project to test grpc between ruby (client) and rust (server)

grpc-example Simple project to test grpc between ruby (client) and rust (server). Usage To simplify a lot this project uses docker and docker compose

Bruno Arueira 2 Oct 14, 2021
A rust client and structures to interact with the Clever-Cloud API.

Clever-Cloud Software Development Kit - Rust edition This crate provides structures and client to interact with the Clever-Cloud API. Status This crat

Clever Cloud 6 Jun 3, 2022
Third party Google DNS client for rust.

google-dns-rs Documentation Install Add the following line to your Cargo.toml file: google-dns-rs = "0.3.0" Usage use google_dns_rs::api::{Dns, DoH, R

Eduardo Stuart 2 Nov 13, 2021
A ddns client written in Rust.

ddns-rs ready for use with one cloudflare A/AAAA record ?? A ddns client written in Rust. Features get public ip cloudflare (A or AAAA record) toml co

Ric Li 1 Oct 25, 2022
Rust client for apache iotdb.

Apache IoTDB Apache IoTDB (Database for Internet of Things) is an IoT native database with high performance for data management and analysis, deployab

Mark Liu 7 Aug 4, 2022
Rust client for Kubernetes

Rust client for Kubernetes API.

null 244 Dec 17, 2022
A Rust based DNS client, server, and resolver

Trust-DNS A Rust based DNS client, server, and Resolver, built to be safe and secure from the ground up. This repo consists of multiple crates: Librar

Benjamin Fry 2.7k Dec 30, 2022
An online version of the popular game four in a row, written in Rust on the server side and Flutter + Dart on the client.

Four in a Row - Server An online version of the popular game four in a row, written in Rust on the server side and Flutter + Dart on the client. Downl

Filippo Orrù 8 Sep 16, 2022
A minimalist socket-based client/server in Rust to illustrate a tutorial

The basics of unix sockets This repository serves as a reference for this tutorial blogpost How to run Install Rust and Cargo, and then do: cargo run

Emmanuel Bosquet 4 Dec 4, 2022
Rust Verbio SpeechCenter Client

The CLI client allows you to launch a single file to the server. It also allows you to use either a grammar or a language model.

Verbio Technologies 3 Sep 16, 2022
Fast Discord RPC Client written in Rust

Discord RPC Client Examples Big image, small image, details and one button discordrpc -c 942151169185316874 -d 'untypeable nickname' --button-1-text '

Oskar 10 Jan 1, 2023
Rust client for Apache Kafka

Kafka Rust Client Project Status This project is starting to be maintained by John Ward, the current status is that I am bringing the project up to da

Kafka Rust 900 Dec 26, 2022
This is a UPnP client library for Rust.

UPnP Client This is a UPNP client library for Rust. Usage Add this to your Cargo.toml: [dependencies] upnp-client = "0.1" Example This example will pr

Tsiry Sandratraina 7 Feb 20, 2023
Socket.io client written in Rust

Rust-socketio-client An implementation of a socket.io client written in the rust programming language. This implementation currently supports revision

Hand of Midas 4 May 9, 2023