javax.mail.MessagingException: Could not connect to SMTP host?

后端 未结 4 1501
谎友^
谎友^ 2021-01-02 19:14

following is my code to send mail:

import java.util.Properties;
import javax.mail.Authenticator;
import javax.mail.Message;
import javax.mail.Message.Recipie         


        
4条回答
  •  既然无缘
    2021-01-02 19:18

    This is these two lines which was casting me the problem :

    m_properties.put("mail.smtp.socketFactory.port", "465");
      m_properties.put("mail.smtp.socketFactory.class","javax.net.ssl.SSLSocketFactory");
    

    and added this line :

    m_properties.put("mail.smtp.starttls.enable", "true");
    

    After removing and adding the above lines of code it worked fine.

提交回复
热议问题