Versão atual:

envio de e-mail está gerando exceções

Olá pessoal,

Não tenho experiência ao desenvolver envio de e-mails, estou tentando fazer um envio na empresa onde trabalho, sei que o e-mail tem criptografia de e-mail TLS, quando executo o código abaixo, ocorre uma exceção, vi que tem algo a ver com certifiado, e SSL, tentei setar como falso o SSL pois vi que n outlook a criptografia de e-mail está como TLS. Alguém já passou por isto?

    public static void main(String[] args) throws EmailException {
        SimpleEmail email = new SimpleEmail();
        email.setHostName("smtp.teste.com.br");                                             
        email.addTo("eduardo@teste.com.br", "haaa"); 
        email.setFrom("eduardo@teste.com.br", "Eu");
        email.setSubject("Teste -> Email simples"); 
        email.setMsg("Teste de Email utilizando commons-email"); 

        email.setAuthentication("eduardo", "123");
        email.setSmtpPort(587);
        email.setSSL(false);
        email.setTLS(true);
        email.send();
        System.out.println("Fim");
    }

stack trace da falha

Exception in thread "main" org.apache.commons.mail.EmailException: Sending the email to the following server failed : smtp.ciss.com.br:587
    at org.apache.commons.mail.Email.sendMimeMessage(Email.java:1138)
    at org.apache.commons.mail.Email.send(Email.java:1163)
    at email.Simples.main(Simples.java:19)
Caused by: javax.mail.SendFailedException: Send failure (javax.mail.MessagingException: Can't send command to SMTP host (javax.net.ssl.SSLHandshakeException: sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target))
    at javax.mail.Transport.send(Transport.java:163)
    at javax.mail.Transport.send(Transport.java:48)
    at org.apache.commons.mail.Email.sendMimeMessage(Email.java:1128)
    ... 2 more
Caused by: javax.mail.MessagingException: Can't send command to SMTP host (javax.net.ssl.SSLHandshakeException: sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target)
    at com.sun.mail.smtp.SMTPTransport.sendCommand(SMTPTransport.java:1420)
    at com.sun.mail.smtp.SMTPTransport.sendCommand(SMTPTransport.java:1408)
    at com.sun.mail.smtp.SMTPTransport.ehlo(SMTPTransport.java:847)
    at com.sun.mail.smtp.SMTPTransport.protocolConnect(SMTPTransport.java:384)
    at javax.mail.Service.connect(Service.java:271)
    at javax.mail.Service.connect(Service.java:91)
    at javax.mail.Service.connect(Service.java:76)
    at javax.mail.Transport.send(Transport.java:94)
    ... 4 more
Caused by: javax.net.ssl.SSLHandshakeException: sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target
    at sun.security.ssl.Alerts.getSSLException(Unknown Source)
    at sun.security.ssl.SSLSocketImpl.fatal(Unknown Source)
    at sun.security.ssl.Handshaker.fatalSE(Unknown Source)
    at sun.security.ssl.Handshaker.fatalSE(Unknown Source)
    at sun.security.ssl.ClientHandshaker.serverCertificate(Unknown Source)
    at sun.security.ssl.ClientHandshaker.processMessage(Unknown Source)
    at sun.security.ssl.Handshaker.processLoop(Unknown Source)
    at sun.security.ssl.Handshaker.process_record(Unknown Source)
    at sun.security.ssl.SSLSocketImpl.readRecord(Unknown Source)
    at sun.security.ssl.SSLSocketImpl.performInitialHandshake(Unknown Source)
    at sun.security.ssl.SSLSocketImpl.writeRecord(Unknown Source)
    at sun.security.ssl.AppOutputStream.write(Unknown Source)
    at com.sun.mail.util.TraceOutputStream.write(TraceOutputStream.java:101)
    at java.io.BufferedOutputStream.flushBuffer(Unknown Source)
    at java.io.BufferedOutputStream.flush(Unknown Source)
    at com.sun.mail.smtp.SMTPTransport.sendCommand(SMTPTransport.java:1418)
    ... 11 more
Caused by: sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target
    at sun.security.validator.PKIXValidator.doBuild(Unknown Source)
    at sun.security.validator.PKIXValidator.engineValidate(Unknown Source)
    at sun.security.validator.Validator.validate(Unknown Source)
    at sun.security.ssl.X509TrustManagerImpl.validate(Unknown Source)
    at sun.security.ssl.X509TrustManagerImpl.checkTrusted(Unknown Source)
    at sun.security.ssl.X509TrustManagerImpl.checkServerTrusted(Unknown Source)
    ... 23 more
Caused by: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target
    at sun.security.provider.certpath.SunCertPathBuilder.engineBuild(Unknown Source)
    at java.security.cert.CertPathBuilder.build(Unknown Source)
    ... 29 more

Versões(2):

Ver a versão formatada

envio de e-mail está gerando excessções

Comentário

new question