0

I have been developing a simple app which is ment to send me emails when a user fills a form.

I have followed tutorials and copied example code. But when I try to run it it throws the following exception:

javax.servlet.ServletContext log: Exception while dispatching incoming RPC call com.google.gwt.user.server.rpc.UnexpectedException: Service method 'public abstract int com.pablo.pabloweb.client.communication.SendEmailService.send(java.lang.String)' threw an unexpected exception: com.google.apphosting.api.ApiProxy$FeatureNotEnabledException: The Socket API will be enabled for this application once billing has been enabled in the admin console. at com.google.gwt.user.server.rpc.RPC.encodeResponseForFailure(RPC.java:389) at com.google.gwt.user.server.rpc.RPC.invokeAndEncodeResponse(RPC.java:579) at com.google.gwt.user.server.rpc.RemoteServiceServlet.processCall(RemoteServiceServlet.java:208) at com.google.gwt.user.server.rpc.RemoteServiceServlet.processPost(RemoteServiceServlet.java:248) ...

My question is: is there any way to use Mail API without setting up billing details? My application is not likely to overtake the limit, by any means.

In case it is needed, this is the code which causes the exception:

public boolean actualSend(String msgText, String subject) {
    Properties props = new Properties();
    Session session = Session.getDefaultInstance(props, null);

    try {
        Message msg = new MimeMessage(session);
        msg.setFrom(new InternetAddress("admin-gmail-email-address"));
        msg.addRecipient(Message.RecipientType.TO,
                         new InternetAddress("another-personal-email-address"));
        msg.setSubject(subject);
        msg.setText(msgText);
        Transport.send(msg);
        return true;
    } catch (AddressException e) {
        return false;
    } catch (MessagingException e) {
        return false;
    }
}
4

1 回答 1

2

如果您只是向自己发送邮件,请使用 MailService 的 sendToAdmins 方法,因为该方法具有最高配额: https ://developers.google.com/appengine/docs/java/javadoc/com/google/appengine/api /mail/MailService#sendToAdmins(com.google.appengine.api.mail.MailService.Message)

顺便说一句,请注意您的应用程序正在获取 Sockets 异常。这意味着您实际上并没有使用 App Engine 邮件服务,几乎可以肯定是因为您没有使用运行时中包含的 JavaMail 类。

无论如何,我建议切换到低级 Mail API 并使用 sendToAdmins。但如果您不这样做,请尝试使用包含的 JavaMail 类,而不是使用您的 App 上传它们。

于 2013-07-29T17:29:20.487 回答