Struct rust_pop3_client::Pop3Connection
source · pub struct Pop3Connection { /* private fields */ }Expand description
POP3 connection
Implementations§
source§impl Pop3Connection
impl Pop3Connection
sourcepub fn new(host: &str, port: u16) -> Result<Pop3Connection, Box<dyn Error>>
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 connectport- Port of the POP3 server to connect
sourcepub fn with_custom_certs(
host: &str,
port: u16,
root_store: RootCertStore
) -> Result<Pop3Connection, Box<dyn Error>>
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 connectport- Port of the POP3 server to connectroot_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);sourcepub fn login(&mut self, user: &str, password: &str) -> Result<(), Box<dyn Error>>
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.
sourcepub fn list(&mut self) -> Result<Vec<Pop3MessageInfo>, Box<dyn Error>>
pub fn list(&mut self) -> Result<Vec<Pop3MessageInfo>, Box<dyn Error>>
Returns id and size of each message.
sourcepub fn retrieve(
&mut self,
message_id: u32,
writer: &mut impl Write
) -> Result<(), Box<dyn Error>>
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 downloadwriter- writer to store message
sourcepub fn top(
&mut self,
message_id: u32,
line_count: u32
) -> Result<String, Box<dyn Error>>
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 messageline_count- count of lines to return from the message body
sourcepub fn list_unique_ids(
&mut self
) -> Result<Vec<Pop3MessageUidInfo>, Box<dyn Error>>
pub fn list_unique_ids( &mut self ) -> Result<Vec<Pop3MessageUidInfo>, Box<dyn Error>>
Returns the unique ids of all messages.