Sample code for 30+ languages & platforms
Rust Requires Chilkat v11.0.0+

POP3 SSL - Read POP3 Email over TLS/SSL on Port 995

Demonstrates how to connect via TLS/SSL to a POP3 server and read email. This assumes that the POP3 server supports SSL.

Chilkat Rust Downloads

Rust

// This example requires the Chilkat API to have been previously unlocked.
// See Global Unlock Sample for sample code.

// The mailman object is used for receiving (POP3) 
// and sending (SMTP) email.
let mailman = chilkat::MailMan::new();

// Set the POP3 server's hostname
mailman.set_mail_host("pop.gmail.com");

// Set the POP3 login/password.
mailman.set_pop_username("****@gmail.com");
mailman.set_pop_password("****");

// Indicate that we want TLS/SSL.  Also, set the port to 995:
mailman.set_mail_port(995);
mailman.set_pop_ssl(true);

let bundle = chilkat::EmailBundle::new();
let keep_on_server = true;
let headers_only = false;
// Irrelevent because we are NOT downloading headers-only
let num_body_lines = 0;
if mailman.fetch_all(keep_on_server, headers_only, num_body_lines, &bundle).is_err() {
    println!("{}", mailman.last_error_text());
    return;
}

let email = chilkat::Email::new();
let mut i = 0;
while i < bundle.message_count() {
    let _ = bundle.email_at(i, &email);

    // Display the From email address and the subject.
    println!("From: {}", email.from());
    println!("Subject: {}", email.subject());
    i = i + 1;
}