classpathx-javamail
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

RE: [Classpathx-javamail] GNU JavaMail CRAM-MD5 Support


From: Jos Collin-ERS,HCLTech
Subject: RE: [Classpathx-javamail] GNU JavaMail CRAM-MD5 Support
Date: Tue, 5 Oct 2010 14:23:13 +0530

> final String userName = ...;
> final String password = ...;
> Authenticator auth = new Authenticator() {
>        protected PasswordAuthentication getPasswordAuthentication() {
>                return new PasswordAuthentication(userName, password);
>        }
> };

Yes, I have already done that in my code. So I will do the following and test 
the code and see whether it authenticate with the SMTP server using CRAM-MD5.

props.put("mail.smtp.auth.mechanisms", "CRAM-MD5")

Thanks for your support,
Jos Collin
________________________________________
From: Chris Burdess address@hidden
Sent: Tuesday, October 05, 2010 2:09 PM
To: Jos Collin-ERS,HCLTech
Cc: address@hidden
Subject: Re: [Classpathx-javamail] GNU JavaMail CRAM-MD5 Support

Jos Collin-ERS,HCLTech wrote:
> Thanks Chris for the information.
>
> So you mean, I have to set the property mail.smtp.auth.mechanisms as 
> props.put("mail.smtp.auth.mechanisms", "CRAM-MD5").

Yes.

> The following is my code where I set the properties. Also, do I have to do 
> anything additional, as the CRAM-MD5 authentication is different from PLAIN? 
> How does it receive the challenge from the server and send the digest back?
>
> Thanks,
> Jos Collin
> -----------------------
>
>
>       //Create a Properties object and set the properties
>        Properties props = new Properties();
>        props.put("mail.transport.protocol", "smtp");
>        props.put("mail.smtp.host", SMTP_HOST_NAME);
>        props.put("mail.smtp.port", SMTP_HOST_PORT);
>        props.put("mail.smtp.auth", "true");

props.put("mail.smtp.auth.mechanisms", "CRAM-MD5");

>        props.put("mail.smtp.ssl.enable", "true");
>
>        //Authenticator can be used only by creating a child class
>        Authenticator auth = new SMTPAuthenticator();

final String userName = ...;
final String password = ...;
Authenticator auth = new Authenticator() {
        protected PasswordAuthentication getPasswordAuthentication() {
                return new PasswordAuthentication(userName, password);
        }
};

>
>        // Create a session using the authenticator object
>        Session mailSession = Session.getDefaultInstance(props, auth);
>
>        Transport transport = mailSession.getTransport();

--
Chris Burdess




reply via email to

[Prev in Thread] Current Thread [Next in Thread]