服务器(腾讯云)java发送邮件报错:Could not connect to SMTP host: smtp.qq.com, port: 25;

properties中加入

properties.setProperty("mail.smtp.auth", "true");//开启认证
    properties.setProperty("mail.debug", "true");//启用调试
    properties.setProperty("mail.smtp.timeout", "1000");//设置链接超时
    properties.setProperty("mail.smtp.port", "465");//设置端口
    properties.setProperty("mail.smtp.socketFactory.port", "465");//设置ssl端口
    properties.setProperty("mail.smtp.socketFactory.fallback", "false");
    properties.setProperty("mail.smtp.socketFactory.class", "javax.net.ssl.SSLSocketFactory");

 

你可能感兴趣的:(Java)