Reputation: 33
I'm trying to send an e-mail to the instructions: https://cloud.google.com/appengine/docs/java/mail/sending-mail-with-mail-api
But I get this error:
com.google.apphosting.api.ApiProxy$CancelledException: The API call remote_socket.CreateSocket() was explicitly cancelled.
at com.google.apphosting.api.ApiProxy.makeSyncCall (ApiProxy.java:118)
at com.google.apphosting.api.ApiProxy.makeSyncCall (ApiProxy.java:67)
at com.google.appengine.api.socket.SocketApiHelper.apiProxyMakeSyncCall (SocketApiHelper.java:93)
at com.google.appengine.api.socket.SocketApiHelper.makeSyncCall (SocketApiHelper.java:58)
at com.google.appengine.api.socket.AppEngineSocketImpl.createSocket (AppEngineSocketImpl.java:497)
at com.google.appengine.api.socket.AppEngineSocketImpl.connectToAddress (AppEngineSocketImpl.java:362)
at com.google.appengine.api.socket.AppEngineSocketImpl.connect (AppEngineSocketImpl.java:352)
at java.net.Socket.connect (Socket.java:612)
at java.net.Socket.connect (Socket.java:540)
at com.sun.mail.util.SocketFetcher.createSocket (SocketFetcher.java:321)
at com.sun.mail.util.SocketFetcher.getSocket (SocketFetcher.java:237)
at com.sun.mail.smtp.SMTPTransport.openServer (SMTPTransport.java:1927)
at com.sun.mail.smtp.SMTPTransport.protocolConnect (SMTPTransport.java:654)
at javax.mail.Service.connect (Service.java:295)
at javax.mail.Service.connect (Service.java:176)
at javax.mail.Service.connect (Service.java:125)
at javax.mail.Transport.send0 (Transport.java:194)
at javax.mail.Transport.send (Transport.java:124)
at ru.usyservice.model.mail.PopupMail.sendMail (PopupMail.java:88)
What could be the reason?
My method:
private void sendMail(String mail) {
Properties props = new Properties();
Session session = Session.getDefaultInstance(props, null);
try {
Message msg = new MimeMessage(session);
msg.setFrom(new InternetAddress("[email protected]", "Mr.x"));
msg.addRecipient(Message.RecipientType.TO,
new InternetAddress("[email protected]", "Mr.y"));
msg.setSubject("Test mail");
msg.setContent(mail, "text/html; charset=\"UTF-8\"");
Transport.send(msg);
} catch (AddressException e) {
e.printStackTrace();
} catch (MessagingException e) {
e.printStackTrace();
} catch (UnsupportedEncodingException e) {
e.printStackTrace();
}
}
Upvotes: 1
Views: 129
Reputation: 33
I found a mistake in pom.xml, library javax.mail has been added, but google is using his lib, which is included in the appengine-api-1.0-sdk I deleted javax.mail, add appengine-api-1.0-sdk in Maven, and it worked!
Upvotes: 1