Monday, December 23, 2013

Re: sending email in GWT project through RPC call

adding javamail-1.4.7\lib jars in webing/lib

i got a different exception :
Exception reading response ( Socket operation timed out: The API call remote_socket.Receive() took too long to respond and was cancelled.)

Le dimanche 6 mai 2012 08:45:06 UTC+2, danit ba a écrit :

I am trying to send html mail in GWT project through RPC call .
the RPC method is invoked successfully, but when the code gets to the
following line:

Transport transport = mailSession.getTransport("smtp");

I get
javax.mail.NoSuchProviderException: Unable to locate provider for
protocol: smtp

i have download javamail 1.4.5 and added the jars to the buildpath
(including smtp.jar ) but nothing helps.

could you please advice ?

* see below  full code:
                final String from = "";
                final String password = "mypassword";
                final String to = "";
                final String body = "<body> bla bla </body>";

            String host = "";
            Properties props = System.getProperties();
            props.put("mail.smtp.starttls.enable", "true");
            props.put("", host);
            props.put("mail.smtp.user", from);
            props.put("mail.smtp.password", password);
            props.put("mail.smtp.port", "587");
            props.put("mail.smtp.auth", "true");
            Session mailSession = Session.getDefaultInstance(props,
            // mailSession.setDebug(true);
            MimeMessage message = new MimeMessage(mailSession);
            message.setSubject("bla bla blu");
            message.setFrom(new InternetAddress(from));
            message.setContent(body, "text/html");
            InternetAddress toAddress = new InternetAddress(to);
            Transport transport = mailSession.getTransport("smtp");
            transport.connect(host, from, password);
            transport.sendMessage(message, message.getAllRecipients());
        } catch (MessagingException e) {

You received this message because you are subscribed to the Google Groups "Google Web Toolkit" group.
To unsubscribe from this group and stop receiving emails from it, send an email to
To post to this group, send email to
Visit this group at
For more options, visit

No comments:

Post a Comment