用java实现发送邮件功能时报错
javax.mail.MessagingException: Could not connect to SMTP host

Exception in thread "main" javax.mail.MessagingException: Could not connect to SMTP host: smtp.suixingpay.com, port: 465, response: -1
	at com.sun.mail.smtp.SMTPTransport.openServer(SMTPTransport.java:2041)
	at com.sun.mail.smtp.SMTPTransport.protocolConnect(SMTPTransport.java:697)
	at javax.mail.Service.connect(Service.java:364)
	at javax.mail.Service.connect(Service.java:245)

解决办法:
props.put(“mail.smtp.ssl.enable”, true);

Properties props = System.getProperties();
props.put("mail.smtp.host", "smtp.suixingpay.com");
props.put("mail.smtp.port", 465);
props.put("mail.smtp.ssl.enable", true);
Session session = Session.getDefaultInstance(props, null);
Logo

魔乐社区(Modelers.cn) 是一个中立、公益的人工智能社区,提供人工智能工具、模型、数据的托管、展示与应用协同服务,为人工智能开发及爱好者搭建开放的学习交流平台。社区通过理事会方式运作,由全产业链共同建设、共同运营、共同享有,推动国产AI生态繁荣发展。

更多推荐