Hello,
I am having this problem if which part of my code is wrong, I already checked a lot of forums and in googles and nothing happens. And why do i keep on receiving
javax.mail.AuthenticationFailedException. I am actually testing this on localhost. I am using Digest-Md5 authentication type, and my server is configured correctly. the username and password are also correct.
I know that i have to set sasl.realm as well (but I am confused which one should is effective to use: .props.put() or tr.setSASLRealm()).
String auth_realm="host.net";
String auth_user = "myuser";
String auth_password="mypassword";
String smtp_add= "smtphost";
String smtp_port = "25";
String to = "recepient@host.net";
Properties props = new Properties();
props.put("mail.smtp.host",smtp_add);
props.put("mail.smtp.port",smtp_port);
props.put("mail.smtp.auth",true);
props.put("mail.trasport.protocol","smtp");
props.setProperty("mail.smtp.quitwait", "false");
props.put("mail.smtp.sasl.realm",auth_realm); //MD5-Digest
Session session = Session.getInstance(props);
Message msg = new MimeMessage(session);
InternetAddress[] address = {new InternetAddress(to)};
msg.setRecipients(Message.RecipientType.TO, address);
msg.setSubject("test");
msg.setSentDate(new Date());
msg.setText("hello");
Transport tr = session.getTransport("smtp");
if(email_auth.equals("DIGEST-MD5")){
if (tr instanceof SMTPTransport) {
((SMTPTransport) tr).setSASLRealm(auth_realm); // i also use props.put("mail.smtp.sasl.realm",auth_realm);
}
}
tr.connect(smtp_add,smtp_port,auth_user,auth_password);
msg.saveChanges();
tr.sendMessage(msg,msg.getAllRecipients());
tr.close();
Please advice if anybody here has an idea. I really need ur help
Thank you
quince
Edited by: quincex on Jul 30, 2008 9:26 AM