this code works fine when i have a java app. I do have the mail.jar in my path. Any ideas?
On Jul 20, 3:27 pm, "Donald W. Long" <[email protected]> wrote: > Do you have the jar for gmail in your path? > > On Jul 19, 7:52 am, Petein <[email protected]> wrote: > > > Hi. I made an RPC for sending an email > > > this is the Impl file: > > > package faceRecognition.server; > > > import com.google.gwt.user.server.rpc.RemoteServiceServlet; > > > import faceRecognition.client.EmailService; > > import faceRecognition.server.Email.SendMail.Gmail; > > > @SuppressWarnings("serial") > > public class EmailServiceImpl extends RemoteServiceServlet implements > > EmailService { > > > @Override > > public String send(String emailTo, String subject, String body) { > > > String msg = ""; > > > msg = Gmail.send("this", emailTo, subject, body); > > > return(msg); > > > } > > > } > > > when i commented out the line "msg = Gmail.send("this", emailTo, > > subject, body);" > > > everything is ok. the problem is in the method Gmail.send: > > > package faceRecognition.server.Email.SendMail; > > > import java.security.Security; > > import java.util.Properties; > > import javax.mail.*; > > import javax.mail.internet.*; > > > public class Gmail { > > > private static final String SMTP_HOST_NAME = "smtp.gmail.com"; > > private static final String SMTP_PORT = "465"; > > private static final String SSL_FACTORY = > > "javax.net.ssl.SSLSocketFactory"; > > > public static String send(String emailFromAddress, String sendTo, > > String subject, String body){ > > > Security.addProvider(new com.sun.net.ssl.internal.ssl.Provider > > ()); > > > String[] emails = new String[1]; > > emails[0] = sendTo; > > try { > > sendSSLMessage("[email protected]", "password", emails, > > subject, > > body, emailFromAddress); > > return(""); > > }catch (Exception e) { > > e.printStackTrace(); > > return(e.getMessage()); > > } > > > } > > > private static void sendSSLMessage(final String username, final > > String password, String recipients[], String subject, > > String message, String from) throws MessagingException { > > boolean debug = true; > > > Properties props = new Properties(); > > props.put("mail.smtp.host", SMTP_HOST_NAME); > > props.put("mail.smtp.auth", "true"); > > props.put("mail.debug", "true"); > > props.put("mail.smtp.port", SMTP_PORT); > > props.put("mail.smtp.socketFactory.port", SMTP_PORT); > > props.put("mail.smtp.socketFactory.class", SSL_FACTORY); > > props.put("mail.smtp.socketFactory.fallback", "false"); > > > Session session = Session.getDefaultInstance(props, > > new javax.mail.Authenticator() { > > > @Override > > protected PasswordAuthentication > > getPasswordAuthentication() { > > return new PasswordAuthentication(username, > > password); > > } > > }); > > > session.setDebug(debug); > > > Message msg = new MimeMessage(session); > > InternetAddress addressFrom = new InternetAddress(from); > > msg.setFrom(addressFrom); > > > InternetAddress[] addressTo = new InternetAddress > > [recipients.length]; > > for (int i = 0; i < recipients.length; i++) { > > addressTo[i] = new InternetAddress(recipients[i]); > > } > > msg.setRecipients(Message.RecipientType.TO, addressTo); > > > // Setting the Subject and Content Type > > msg.setSubject(subject); > > msg.setContent(message, "text/html"); > > //Transport.send(msg); > > > javax.mail.Transport.send(msg); //HERE I GET THE FOLLOWING > > ERROR > > } > > > } > > > The error which i get is: > > > DEBUG: getProvider() returning javax.mail.Provider > > [TRANSPORT,gm,com.google.appengine.api.mail.stdimpl.GMTransport] > > com.google.apphosting.api.ApiProxy$CallNotFoundException: The API > > package 'mail' or call 'Send()' was not found. > > at com.google.apphosting.api.ApiProxy.makeSyncCall(ApiProxy.java:70) > > at com.google.appengine.api.mail.MailServiceImpl.doSend > > (MailServiceImpl.java:96) > > at com.google.appengine.api.mail.MailServiceImpl.send > > (MailServiceImpl.java:33) > > at com.google.appengine.api.mail.stdimpl.GMTransport.sendMessage > > (GMTransport.java:247) > > at javax.mail.Transport.send0(Transport.java:191) > > at javax.mail.Transport.send(Transport.java:120) > > at faceRecognition.server.Email.SendMail.Gmail.sendSSLMessage > > (Gmail.java:75) > > at faceRecognition.server.Email.SendMail.Gmail.send(Gmail.java:26) > > at > > faceRecognition.server.EmailServiceImpl.send(EmailServiceImpl.java: > > 17) > > at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) > > at sun.reflect.NativeMethodAccessorImpl.invoke > > (NativeMethodAccessorImpl.java:39) > > at sun.reflect.DelegatingMethodAccessorImpl.invoke > > (DelegatingMethodAccessorImpl.java:25) > > at java.lang.reflect.Method.invoke(Method.java:597) > > at com.google.gwt.user.server.rpc.RPC.invokeAndEncodeResponse > > (RPC.java:527) > > at com.google.gwt.user.server.rpc.RemoteServiceServlet.processCall > > (RemoteServiceServlet.java:166) > > at com.google.gwt.user.server.rpc.RemoteServiceServlet.doPost > > (RemoteServiceServlet.java:86) > > at javax.servlet.http.HttpServlet.service(HttpServlet.java:637) > > at javax.servlet.http.HttpServlet.service(HttpServlet.java:717) > > at > > org.mortbay.jetty.servlet.ServletHolder.handle(ServletHolder.java: > > 487) > > at org.mortbay.jetty.servlet.ServletHandler.handle > > (ServletHandler.java:362) > > at org.mortbay.jetty.security.SecurityHandler.handle > > (SecurityHandler.java:216) > > at org.mortbay.jetty.servlet.SessionHandler.handle > > (SessionHandler.java:181) > > at org.mortbay.jetty.handler.ContextHandler.handle > > (ContextHandler.java:729) > > at org.mortbay.jetty.webapp.WebAppContext.handle(WebAppContext.java: > > 405) > > at org.mortbay.jetty.handler.HandlerWrapper.handle > > (HandlerWrapper.java:152) > > at org.mortbay.jetty.handler.RequestLogHandler.handle > > (RequestLogHandler.java:49) > > at org.mortbay.jetty.handler.HandlerWrapper.handle > > (HandlerWrapper.java:152) > > at org.mortbay.jetty.Server.handle(Server.java:324) > > at > > org.mortbay.jetty.HttpConnection.handleRequest(HttpConnection.java: > > 505) > > at org.mortbay.jetty.HttpConnection$RequestHandler.content > > (HttpConnection.java:843) > > at org.mortbay.jetty.HttpParser.parseNext(HttpParser.java:647) > > at org.mortbay.jetty.HttpParser.parseAvailable(HttpParser.java:211) > > at org.mortbay.jetty.HttpConnection.handle(HttpConnection.java:380) > > at org.mortbay.io.nio.SelectChannelEndPoint.run > > (SelectChannelEndPoint.java:395) > > at org.mortbay.thread.QueuedThreadPool$PoolThread.run > > (QueuedThreadPool.java:488) > > > What is going on? This code sends email fine when i have it in my > > desktop app. Here this exception occurs. Any ideas? > > --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Google Web Toolkit" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/Google-Web-Toolkit?hl=en -~----------~----~----~----~------~----~------~--~---
