我在尝试通过 servlet 中的 gmail smtp 发送电子邮件时遇到此错误,它在测试时可以在本地工作,但不能在 google 引擎内部我在 web-inf/libs [activation.jar-smtp.jar-mailapi.jar - mail. jar] 知道如何修复它!
错误:
javax.servlet.ServletContext log: unavailable java.lang.SecurityException: SHA1 digest
error for javax/mail/Message.class at com.google.appengine.run
代码快照:
Properties props = new Properties();
props.setProperty("mail.transport.protocol", "smtp");
props.setProperty("mail.host", "smtp.gmail.com");
props.put("mail.smtp.auth", "true");
props.put("mail.smtp.port", "465");
//props.put("mail.debug", "true");
props.put("mail.smtp.socketFactory.port", "465");
props.put("mail.smtp.socketFactory.class","javax.net.ssl.SSLSocketFactory");
props.put("mail.smtp.socketFactory.fallback", "false");
javax.mail.Session sess = javax.mail.Session.getInstance(props);
Transport transport = sess.getTransport();
transport.connect();
transport.send(message);