2

I wonder if it is possible to connect to Hotmail with JavaMail?

I've tried this but it doesn't work, connection refused...

    String host = "pop3.live.com";
    String username = "laqetqetqet@hotmail.com";
    String password = "rqetqetq";

    Session session;
    Store store;

    String SSL_FACTORY = "javax.net.ssl.SSLSocketFactory";

    Properties pop3Props = new Properties();

    pop3Props.setProperty("mail.pop3.socketFactory.class", SSL_FACTORY);
    pop3Props.setProperty("mail.pop3.socketFactory.fallback", "false");
    pop3Props.setProperty("mail.pop3.port",  "995");
    pop3Props.setProperty("mail.pop3.socketFactory.port", "995");

    URLName url = new URLName("pop3", host, 995, "", username, password);

    session = Session.getInstance(pop3Props, null);
    store = new POP3SSLStore(session, url);
    store.connect();

Anyone already succeeded to do this?

Marcelo
  • 2,232
  • 3
  • 22
  • 31
Sebastien Lorber
  • 89,644
  • 67
  • 288
  • 419
  • No exceptions for me (just replaced email/password). Perhaps, you should see if there's some kind of firewall or check hotmail settings. – Nikita Rybak Jun 18 '10 at 14:02

2 Answers2

6

Hotmail now supports pop3 (through SSL).

Thus, you need the following settings:

pop3Props.setProperty("mail.pop3.ssl.enable", "true");

For all other properties, you must add a "s" in the properties string (so it says "pop3s" instead of "pop3"):

pop3Props.setProperty("mail.pop3s.socketFactory.class", SSL_FACTORY); pop3Props.setProperty("mail.pop3s.socketFactory.fallback", "false"); pop3Props.setProperty("mail.pop3s.port", "995"); pop3Props.setProperty("mail.pop3s.socketFactory.port", "995");

For me, the following code works nicely:

String host = "pop3.live.com";
String username = "laqetqetqet@hotmail.com";
String password = "rqetqetq";

Properties pop3Props = new Properties();
pop3Props.setProperty("mail.pop3s.port",  "995");

Session session = Session.getInstance(pop3Props, null);
Store store = session.getStore("pop3s");
store.connect(host, 995, username, password);
Timo Ernst
  • 15,243
  • 23
  • 104
  • 165
1

You could try this SourceForge project

MrPostman is an email gateway from local POP clients like Microsoft Outlook, Mozilla's mail client etc. to different web mail services like Yahoo and Hotmail.It is being designed for extensibility so is easy to add more web mail services to it.

Romain Hippeau
  • 24,113
  • 5
  • 60
  • 79