67,549
社区成员




type Exception report
message
descriptionThe server encountered an internal error () that prevented it from fulfilling this request.
exception
org.apache.jasper.JasperException: javax.ejb.EJBException
root cause
javax.ejb.EJBException
root cause
java.lang.SecurityException: Access to default session denied
String from = "*****@163.com";
String host = "smtp.163.com";
String to = "***@hotmail.com";
Properties props = System.getProperties();
props.put("mail.smtp.host", host);
props.put("mail.smtp.auth", "true");
MyAuthenticator myauth = new MyAuthenticator("*****@163.com", "******"); //我有一个继承javax.mail.Authenticator的类
Session session = Session.getDefaultInstance(props, myauth);
MimeMessage message = new MimeMessage(session);
message.setFrom(new InternetAddress(from));
message.addRecipient(Message.RecipientType.TO,
new InternetAddress(to));
message.setSubject("test program");
message.setText("This is a test to inform you by java mail");
message.saveChanges();
Transport.send(message);