Question

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;
    }
}
Was it helpful?

Solution

If you're just sending mail to yourself, then use the sendToAdmins method of the MailService as that has the highest quotas: https://developers.google.com/appengine/docs/java/javadoc/com/google/appengine/api/mail/MailService#sendToAdmins(com.google.appengine.api.mail.MailService.Message)

By the way, note that your App is getting a Sockets exception. That means that you aren't actually using the App Engine Mail Service, almost certainly because you aren't using the JavaMail classes that are included in the runtime.

In any case, I recommend switching to the low level Mail API and using sendToAdmins. But if you don't do that, try using the included JavaMail classes instead of uploading them with your App.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top