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: Chris Burdess
Subject: Re: [Classpathx-javamail] GNU JavaMail CRAM-MD5 Support
Date: Tue, 5 Oct 2010 09:39:47 +0100

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]