从Appengine发送邮件

时间:2013-02-12 15:30:58

标签: java google-app-engine email

我正在关注此tutorial以从应用引擎发送电子邮件。

    Properties props = new Properties();
    Session session = Session.getDefaultInstance(props, null);
    String msgBody = "...";
    try {
        Message msg = new MimeMessage(session);
        msg.setFrom(new InternetAddress("myAppAdmin@gmail.com"));
        msg.addRecipient(Message.RecipientType.TO,
                new InternetAddress("AnotherMailOfMine@gmail.com"));
        msg.setSubject("Your Example.com account has been activated");
        msg.setText(msgBody);
        Transport.send(msg);

    } catch (AddressException e) {
        // ...
    } catch (MessagingException e) {
        // ...
    }

但是我得到了这个错误

javax.servlet.ServletContext log: Exception while dispatching incoming RPC call
com.google.gwt.user.server.rpc.UnexpectedException: Service method 'public abstract    java.lang.Boolean net.adeptus.client.util.UtilService.sendMailActivation(net.adeptus.client.DTO.PlayerDTO)' threw an unexpected exception: java.lang.NoClassDefFoundError: com/sun/mail/util/TraceOutputStream
at com.google.gwt.user.server.rpc.RPC.encodeResponseForFailure(RPC.java:385)
at com.google.gwt.user.server.rpc.RPC.invokeAndEncodeResponse(RPC.java:588)
at com.google.gwt.user.server.rpc.RemoteServiceServlet.processCall(RemoteServiceServlet.java:208)
at com.google.gwt.user.server.rpc.RemoteServiceServlet.processPost(RemoteServiceServlet.java:248)
at 

我已经检查过我没有使用Oracle jar并且邮件发件人存在。

有什么想法吗?

1 个答案:

答案 0 :(得分:-1)

此错误表示在编译时发现了此类定义,但在运行时未找到。

尝试将JavaMail api文件添加到LIB文件夹中。

(我个人使用1.4.1版本。(http://download.java.net/maven/1/javax.mail/jars/))

希望这会有所帮助