Unable to connect to SMTP Port no 465

6.7k views Asked by At

I am not able to connect to smtp port no 465, which uses SSL authentication. Earlier it used to work in default port 25, but have changed the setting to point to 465 for outbound emails for all outgoing emails. This works perfectly fine when i use outlook but shows that it cannot connect to port 465.

Below is the error.

javax.mail.SendFailedException: Sending failed;
  nested exception is:
        javax.mail.MessagingException: Could not connect to SMTP host: smtp.bizmail.yahoo.com, port: 465
        at javax.mail.Transport.send0(Transport.java:218)
        at javax.mail.Transport.send(Transport.java:80)

And below is the Javax Mail setting that i use.

 Properties props = System.getProperties(); 
    props.put("mail.smtp.host", host);
    props.put("mail.smtp.socketFactory.class", 
    props.setProperty("mail.smtp.port", "465");
    props.put("mail.smtp.ssl.enable", "true");
    props.put("mail.smtp.starttls.enable","true");
    props.put("mail.server.username", "[email protected]");
    props.put("mail.server.password", "test123");
    props.put("mail.smtp.auth", "true");
    props.setProperty("mail.smtp.submitter",   authenticator.getPasswordAuthentication().getUserName()); 
    Session session = Session.getInstance(props, authenticator);
    session.setDebug(sessionDebug);

Any help would be much appreciated.

1

There are 1 answers

6
Jhanvi On BEST ANSWER

As the log says, smtp.bizmail.yahoo.com at port 465 cannot be connected, if you are using gmail, the host should be:smtp.gmail.com.

For reference:

Gmail- Host: smtp.gmail.com , Port: 465

Hotmail- Host: smtp.live.com , Port: 587

Yahoo- Host: smtp.mail.yahoo.com , Port: 465