Skip to content

Instantly share code, notes, and snippets.

@aspose-com-gists
Last active May 13, 2022 05:40
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save aspose-com-gists/7c5b8a4ddb79171f1b12ab6a777674d7 to your computer and use it in GitHub Desktop.
Save aspose-com-gists/7c5b8a4ddb79171f1b12ab6a777674d7 to your computer and use it in GitHub Desktop.
Connect to POP3 Servers in Java
// Create an instance of HttpProxy
HttpProxy proxy = new HttpProxy("18.222.124.59", 8080);
// Create Pop3Client
try (Pop3Client client = new Pop3Client("imap.domain.com", "username", "password")) {
// Set HTTP proxy
client.setProxy(proxy);
// Access mailbox
Pop3MailboxInfo mailboxInfo = client.getMailboxInfo();
}
// Create an instance of the Pop3Client class
Pop3Client client = new Pop3Client("pop.domain.com", "username", "password");
// Set proxy address, port and proxy
String proxyAddress = "192.168.203.142";
int proxyPort = 1080;
SocksProxy proxy = new SocksProxy(proxyAddress, proxyPort, SocksVersion.SocksV5);
client.setProxy(proxy);
// Access mailbox
Pop3MailboxInfo mailboxInfo = client.getMailboxInfo();
// Create an instance of the Pop3Client class
Pop3Client client = new Pop3Client();
// Specify host, username and password, Port and SecurityOptions for your client
client.setHost("pop.gmail.com");
client.setUsername("your.username@gmail.com");
client.setPassword("your.password");
client.setPort(995);
client.setSecurityOptions(SecurityOptions.Auto);
System.out.println("Connecting to POP3 server using SSL.");
// Access mailbox
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment