Discussion:
starting today: send.Mail took too long to respond
James Briant
2011-09-13 10:05:51 UTC
Permalink
My app can't send email any more. I get this exception every time:

com.google.apphosting.api.ApiProxy$ApiDeadlineExceededException: The API
call mail.Send() took too long to respond and was cancelled

Here's the time for the incoming call: ms=6640 cpu_ms=1568 api_cpu_ms=658
cpm_usd=0.069988

What's going on and what do I do about it?
--
You received this message because you are subscribed to the Google Groups "Google App Engine for Java" group.
To view this discussion on the web visit https://groups.google.com/d/msg/google-appengine-java/-/bn-JT0OHlQUJ.
To post to this group, send email to google-appengine-java-/JYPxA39Uh5TLH3MbocFF+G/***@public.gmane.org
To unsubscribe from this group, send email to google-appengine-java+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/***@public.gmane.org
For more options, visit this group at http://groups.google.com/group/google-appengine-java?hl=en.
Sudhakar Abraham
2011-09-13 12:19:50 UTC
Permalink
Here is a sample code segment ( which is working ) for sending mail
using Google App Engine. Please see the documentation @ "http://
download.oracle.com/javaee/1.4/api/index.html". Hope it helps.

S. Abraham
www.DataStoreGwt.com

// client side code

import com.google.gwt.core.client.EntryPoint;
import com.google.gwt.event.dom.client.ClickEvent;
import com.google.gwt.event.dom.client.ClickHandler;
import com.google.gwt.http.client.Request;
import com.google.gwt.http.client.RequestBuilder;
import com.google.gwt.http.client.RequestCallback;
import com.google.gwt.http.client.RequestException;
import com.google.gwt.http.client.Response;
import com.google.gwt.user.client.Window;
import com.google.gwt.user.client.ui.Button;
import com.google.gwt.user.client.ui.RootPanel;



public class MainEntry implements EntryPoint {
RequestBuilder rb = null;

@Override
public void onModuleLoad() {
// Window.Location.replace("/hello");
rb = new RequestBuilder(RequestBuilder.POST, "mailserver");
rb.setCallback(new RequestCallback() {

@Override
public void onResponseReceived(Request request, Response response)
{
// TODO Auto-generated method stub
Window.alert("Mail send");
}

@Override
public void onError(Request request, Throwable exception) {
// TODO Auto-generated method stub

}
});
Button button = new Button("Mail service");
button.addClickHandler(new ClickHandler() {

@Override
public void onClick(ClickEvent event) {
// TODO Auto-generated method stub

try {
rb.send();
} catch (RequestException e) {

}
}
});

RootPanel.get().add(button);
}
}

// server side code

import java.io.UnsupportedEncodingException;
import java.util.Properties;
import javax.mail.Message;
import javax.mail.MessagingException;
import javax.mail.Multipart;
import javax.mail.Session;
import javax.mail.Transport;
import javax.mail.internet.AddressException;
import javax.mail.internet.InternetAddress;
import javax.mail.internet.MimeBodyPart;
import javax.mail.internet.MimeMessage;
import javax.mail.internet.MimeMultipart;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

public class MailServlet extends HttpServlet {
private static final long serialVersionUID = 1L;
public void doPost(HttpServletRequest req, HttpServletResponse resp)
{
System.out.println("Mail Servlet is called");
Properties properties = new Properties();
Session session = Session.getDefaultInstance(properties, null);
String message = "Welcome to www.datastoregwt.com";
try
{
Message msg = new MimeMessage(session);
msg.setFrom(new
InternetAddress("frommailaddress-***@public.gmane.org"));
msg.addRecipient(Message.RecipientType.TO, new
InternetAddress("tomailaddress-***@public.gmane.org"));
msg.setSubject("Invitation from www.tanya.com");
msg.setText(message);
Transport.send(msg);

}
catch (AddressException e1)
{

}
catch (MessagingException e2)
{

}
catch (UnsupportedEncodingException e)
{
e.printStackTrace();
}
}
}
Post by James Briant
com.google.apphosting.api.ApiProxy$ApiDeadlineExceededException: The API
call mail.Send() took too long to respond and was cancelled
Here's the time for the incoming call: ms=6640 cpu_ms=1568 api_cpu_ms=658
cpm_usd=0.069988
What's going on and what do I do about it?
--
You received this message because you are subscribed to the Google Groups "Google App Engine for Java" group.
To post to this group, send email to google-appengine-java-/***@public.gmane.org.
To unsubscribe from this group, send email to google-appengine-java+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/***@public.gmane.org
For more options, visit this group at http://groups.google.com/group/google-appengine-java?hl=en.
Continue reading on narkive:
Loading...