Rust
Rust
Send a Raw POP3 Command
See more POP3 Examples
Demonstrates the Chilkat MailMan.Pop3SendRawCommand method, which sends a raw command to the POP3 server and returns the server's response. The second argument specifies the charset to use if the command contains non-US-ASCII characters. This example sends the POP3 STAT command within an open session.
Background: POP3 is a simple line-based text protocol — the client sends short commands like
STAT, LIST, UIDL, or RETR and the server replies with +OK or -ERR. This method is an escape hatch for issuing a command Chilkat doesn't wrap directly, or a server-specific extension. Note that the session must already be open, since a raw command assumes an authenticated connection.Chilkat Rust Downloads
// Demonstrates the MailMan.Pop3SendRawCommand method, which sends a raw command to the POP3
// server and returns the server's response. The second argument is the charset used if the
// command contains non-US-ASCII characters.
let mailman = chilkat::MailMan::new();
// Configure the POP3 server connection.
mailman.set_mail_host("pop.example.com");
mailman.set_mail_port(995);
mailman.set_pop_ssl(true);
mailman.set_pop_username("user@example.com");
mailman.set_pop_password("myPassword");
if mailman.pop3_begin_session().is_err() {
println!("{}", mailman.last_error_text());
return;
}
// Send the raw POP3 STAT command, which returns the message count and maildrop size.
let Ok(response) = mailman.pop3_send_raw_command("STAT", "us-ascii") else {
println!("{}", mailman.last_error_text());
return;
};
println!("STAT response: {}", response);
if mailman.pop3_end_session().is_err() {
println!("{}", mailman.last_error_text());
return;
}