View Single Post
Old 09-29-2012, 05:38 AM   PM User | #1
ibnmvungi
New to the CF scene

 
Join Date: Apr 2012
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
ibnmvungi is an unknown quantity at this point
Exclamation new PasswordAuthentication class error

i have this code for sending mail.i am using netbean and it shows an error on line
Code:
 return new PasswordAuthentication("matumiziyangu@gmail.com",password.toCharArray());
.

the error says

"incompatible types
required: javax.mail.PasswordAuthentication
found: java.net.PasswordAuthentication"

below is the source code.


Code:
Properties props = new Properties();
props.put("mail.smtp.host", "smtp.gmail.com");
props.put("mail.smtp.socketFactory.port", "465");
props.put("mail.smtp.socketFactory.class", "javax.net.ssl.SSLSocketFactory");
props.put("mail.smtp.auth", "true");
props.put("mail.smtp.port", "465");
final String password="accdsss";
Session ses = Session.getDefaultInstance(props,
new javax.mail.Authenticator() {








protected javax.mail.PasswordAuthentication getPasswordAuthentication() {

return new PasswordAuthentication("matumiziyangu@gmail.com",password.toCharArray());

}
});

try {
Message msg = new MimeMessage(ses);
msg.setFrom(new InternetAddress("matumiziyangu@gmail.com"));
msg.setRecipients(Message.RecipientType.TO, InternetAddress.parse("ibnmvungi@live.com"));
msg.setSubject("high its me");
msg.setText("how are you there friend.this is java");
Transport.send(msg);
JOptionPane.showMessageDialog(null, "message sent");
} catch (Exception e) {
JOptionPane.showMessageDialog(null, e);
}
please any one with idea to help me this out.
ibnmvungi is offline   Reply With Quote