pub struct Pop3Connection { /* private fields */ }
Expand description

POP3 connection

Implementations§

source§

impl Pop3Connection

source

pub fn new(host: &str, port: u16) -> Result<Pop3Connection, Box<dyn Error>>

Returns a new POP3 connection.

Arguments
  • host - IP-Address or host name of the POP3 server to connect
  • port - Port of the POP3 server to connect
source

pub fn with_custom_certs( host: &str, port: u16, root_store: RootCertStore ) -> Result<Pop3Connection, Box<dyn Error>>

Returns a new POP3 connection with custom certificates.

Arguments
  • host - IP-Address or host name of the POP3 server to connect
  • port - Port of the POP3 server to connect
  • root_store - Store of trusted (root) certificates.
Examples
use rust_pop3_client::Pop3Connection;
use rustls::RootCertStore;

let mut root_store = RootCertStore::empty();
for cert in rustls_native_certs::load_native_certs().unwrap() {
    root_store.add(&rustls::Certificate(cert.0)).unwrap();
}
 
let connection = Pop3Connection::with_custom_certs("", 995, root_store);
source

pub fn login(&mut self, user: &str, password: &str) -> Result<(), Box<dyn Error>>

Authenticate a POP3 session using username and password.

This is usually the first set of commands after a POP3 session is established.

Arguments
  • user - Name of the user, typically it’s e-mail address.
  • password - Password of the user.
source

pub fn stat(&mut self) -> Result<Pop3Stat, Box<dyn Error>>

Returns maildrop statistics.

source

pub fn list(&mut self) -> Result<Vec<Pop3MessageInfo>, Box<dyn Error>>

Returns id and size of each message.

source

pub fn get_message_size( &mut self, message_id: u32 ) -> Result<u32, Box<dyn Error>>

Returns the size of a given message.

Arguments
  • message_id - id of the message to query
source

pub fn retrieve( &mut self, message_id: u32, writer: &mut impl Write ) -> Result<(), Box<dyn Error>>

Downloads a given message.

Arguments
  • message_id - id of the message to download
  • writer - writer to store message
source

pub fn delete(&mut self, message_id: u32) -> Result<(), Box<dyn Error>>

Deletes a given message.

Arguments
  • message_id - id of the message to download
source

pub fn reset(&mut self) -> Result<(), Box<dyn Error>>

Unmark any messages marked as delete.

source

pub fn top( &mut self, message_id: u32, line_count: u32 ) -> Result<String, Box<dyn Error>>

Returns the message header an a given number of lines from the message.

Arguments
  • message_id - id of the message
  • line_count - count of lines to return from the message body
source

pub fn list_unique_ids( &mut self ) -> Result<Vec<Pop3MessageUidInfo>, Box<dyn Error>>

Returns the unique ids of all messages.

source

pub fn get_unique_id( &mut self, message_id: u32 ) -> Result<String, Box<dyn Error>>

Returns the unique id of a given message.

Arguments
  • message_id - id of the message

Trait Implementations§

source§

impl Drop for Pop3Connection

source§

fn drop(&mut self)

Closes POP3 connection on drop.

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for Twhere T: ?Sized,

const: unstable · source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere T: ?Sized,

const: unstable · source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

const: unstable · source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for Twhere U: From<T>,

const: unstable · source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T, U> TryFrom<U> for Twhere U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
const: unstable · source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for Twhere U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
const: unstable · source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.