Unable to connect to SMTP Port no 465

坚强是说给别人听的谎言 提交于 2021-02-08 06:38:35

问题


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", "test@gamil.com");
    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:


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



来源:https://stackoverflow.com/questions/20566346/unable-to-connect-to-smtp-port-no-465

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!