Posted By:
Siddhi_Desai
Posted On:
Friday, June 21, 2002 03:05 AM
I am getting AuthenticationFailedException when trying to send a mail to a Yahoo Account.The code is as below: Properties props = new Properties();props.put("mail.smtp.host", smtpHost ); props.put("mail.smtp.auth", "true"); Session session = Session.getInstance(props,null);MimeMessage message = new MimeMessage(session);Address fromAddress = new InternetAddress(from);message.setFrom(fromAddress);Address[] toAddresses = InternetAddress.parse(to);message.setRecipients(Message.RecipientType.TO,toAddresses);message.setSubject(subject);message.setText(text); PasswordAuthentication pauth = new Passwordauthentication("username","password");URLName url = new URLName("smtp",smtpHost,-1,"",&
More>>
I am getting AuthenticationFailedException when trying to send a mail to a Yahoo Account.The code is as below:
Properties props = new Properties();props.put("mail.smtp.host", smtpHost ); props.put("mail.smtp.auth", "true"); Session session = Session.getInstance(props,null);MimeMessage message = new MimeMessage(session);Address fromAddress = new InternetAddress(from);message.setFrom(fromAddress);Address[] toAddresses = InternetAddress.parse(to);message.setRecipients(Message.RecipientType.TO,toAddresses);message.setSubject(subject);message.setText(text);
PasswordAuthentication pauth = new Passwordauthentication("username","password");URLName url = new URLName("smtp",smtpHost,-1,"","username","password");
session.setPasswordAuthentication(url,pauth);
Transport transport = session.getTransport("smtp");transport.connect(smtpHost,"username","password");
transport.send(message);transport.close();
Kindly give a solution.
Thanx in Advance.
<<Less