Thursday, May 10, 2012

Re: sending email in GWT project through RPC call

Hi,

What do your web.xml and context.xml look like?

-> web.xml:

...

<context-param>
<param-name>MAIL-NAME</param-name>
<param-value>mail/GmailSmtpServer</param-value>
<description>The name of the mail Session used by sample
application.</description>
</context-param>

->

-> context.xml:

<Resource name="mail/GmailSmtpServer"
auth="Container"
type="javax.mail.Session"
mail.transport.protocol="smtp"
mail.smtp.host="smtp.gmail.com"
mail.smtp.port="465"
mail.smtp.auth="true"
mail.smtp.user="user.name@gmail.com"
password="password"
mail.smtp.starttls.enable="true"

mail.smtp.socketFactory.class="javax.net.ssl.SSLSocketFactory"
mail.debug="true" />

->

Are you running hosted mode (no JNDI support ?) or have you deployed
the app to Tomcat and placed the jars in \lib (activation and mail)?

Cheers
Rob

http://code.google.com/p/gwt-cx/


On May 6, 4:45 pm, danit ba <dani...@gmail.com> wrote:
> Hi,
>
> 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:
> try{
>                 final String from = "mym...@gmail.com";
>                 final String password = "mypassword";
>                 final String to = "maildest...@gmail.com";
>                 final String body = "<body> bla bla </body>";
>
>             String host = "smtp.gmail.com";
>             Properties props = System.getProperties();
>             props.put("mail.smtp.starttls.enable", "true");
>             props.put("mail.smtp.host", 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,
> null);
>             // 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);
>             message.addRecipient(Message.RecipientType.TO,
> toAddress);
>             Transport transport = mailSession.getTransport("smtp");
>             transport.connect(host, from, password);
>             transport.sendMessage(message, message.getAllRecipients());
>             transport.close();
>         } catch (MessagingException e) {
>                 e.printStackTrace();
>                  }

--
You received this message because you are subscribed to the Google Groups "Google Web Toolkit" group.
To post to this group, send email to google-web-toolkit@googlegroups.com.
To unsubscribe from this group, send email to google-web-toolkit+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/google-web-toolkit?hl=en.

0 Comments:

Post a Comment

Subscribe to Post Comments [Atom]

<< Home


Real Estate