users@glassfish.java.net

Re: JavaMail datasource with TLS/SSL, username and password

From: Alexis Moussine-Pouchkine <alexis.mp_at_sun.com>
Date: Mon, 30 Jun 2008 21:02:55 +0200

Hi Ryan,

Would this help ?

         ...
         Properties props = new Properties();
         props.put("mail.smtp.auth", "true");
         props.put("mail.smtp.host", "smtp.host.foo");
         props.put("mail.smtp.port", "587");
         props.put("mail.from", "foo_at_bar.com");

         Authenticator auth = Utils.getAuthenticator();
         Session session = Session.getInstance(props, auth);
         session.setDebug(false);
         ...



     public static Authenticator getAuthenticator() {
         return new Authenticator() {
             @Override
             protected PasswordAuthentication
getPasswordAuthentication() {
                 return new PasswordAuthentication(user, password);
             }
         };
     }



I'll admit I didn't use this with gmail but it does work with Sun's
SMTP.

-Alexis

On Jun 30, 2008, at 19:25, Ryan de Laplante wrote:

> Hi,
>
> I'm having difficulty figuring out how to configure a JavaMail
> datasource for either my employer's SMTP server for GMail's. They
> both use TLS, username and password.
>
> So far the most helpful page I found with JavaMail *properties* to
> configure is here:
>
> http://www.jroller.com/eyallupu/entry/javamail_sending_embedded_image_in
>
> Can anyone help? How do I put in a username and password? I tried
> mail.password but it still doesn't work.
>
>
> Thanks,
> Ryan
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe_at_glassfish.dev.java.net
> For additional commands, e-mail: users-help_at_glassfish.dev.java.net
>