Pessoal estou tentando enviar um email autenticado, mas estou obtento o seguinte erro:
javax.mail.SendFailedException: Sending failed;
nested exception is:
class javax.mail.AuthenticationFailedException
at javax.mail.Transport.send0(Transport.java:218)
at javax.mail.Transport.send(Transport.java:80)
se eu tentar fazer :
mailSession.getTransport().connect();
recebo a seguinte exceção:
javax.mail.NoSuchProviderException: Invalid protocol: null
at javax.mail.Session.getProvider(Session.java:412)
at javax.mail.Session.getTransport(Session.java:631)
at javax.mail.Session.getTransport(Session.java:612)
public void sendMail(String to) throws AddressException, MessagingException{
Properties properties = new Properties();
properties.put("mail.smtp.host", mailServer);
properties.put("mail.smtp.auth", "true");
Authenticator auth = new Autenticar();
Session mailSession = Session.getInstance(properties, auth);
InternetAddress remetente = new InternetAddress(from);
InternetAddress destinario = new InternetAddress(to);
Message objMsg = new MimeMessage(mailSession);
objMsg.setFrom(remetente);
objMsg.setRecipient(Message.RecipientType.TO, destinario);
objMsg.setSubject(subjact);
objMsg.setContent(msg.toString(), "text/plain");
Transport.send(objMsg);
}
valeu ;)
