Javamail - Verbindung zum SMTP-Host konnte nicht hergestellt werden

Ich versuche eine E-Mail von meinem Java zu senden und konnte keine Verbindung zu meinem Host herstellen. Hier meine Codes:

public class sendEmail implements Runnable{
     @Override
     public void run(){
        try{
            final String username = "user", password = "pass", from = "[email protected]", to = "[email protected]";

            Properties props = new Properties();
            props.setProperty("mail.smtp.user", username);
            props.setProperty("mail.smtp.host", "mail.host.com");
            props.setProperty("mail.smtp.ssl.enable", "true"); 
            props.setProperty("mail.smtp.port", "465");
            props.setProperty("mail.smtp.starttls.enable", "true");
            props.setProperty("mail.smtp.debug", "true");
            props.setProperty("mail.smtp.auth", "true");
            props.setProperty("mail.smtp.socketFactory.port", "465");
            props.setProperty("mail.smtp.socketFactory.class", "javax.net.ssl.SSLSocketFactory");
            props.setProperty("mail.smtp.socketFactory.fallback", "false");
            Authenticator auth = new SMTPAuthenticator();
            Session session = Session.getInstance(props, auth);
            session.setDebug(true);

            Message msg = new MimeMessage(session);
            try{
                msg.setSubject("Test SMTP");
                msg.setFrom(new InternetAddress(from));
                msg.setRecipients(Message.RecipientType.TO, InternetAddress.parse(to));
                Transport transport = session.getTransport("smtp");
                transport.connect("mail.itbuntuksemua.com", username, password);
                transport.sendMessage(msg, msg.getAllRecipients());
                transport.close();
                System.out.println("Done");
            }catch(MessagingException | NumberFormatException | HeadlessException ex){
                ex.printStackTrace();
            }
        }catch(UnknownHostException | NumberFormatException ex){
            ex.printStackTrace();
        }
     }
 }

nd hier meinSMTPAuthenticator() codes:

private class SMTPAuthenticator extends javax.mail.Authenticator {
    @Override
    public PasswordAuthentication getPasswordAuthentication() {
        String username = "user"; 
        String password = "pass";
        return new PasswordAuthentication(username, password);
    } 
}

und hier nochmal meine Fehler melden:

DEBUG: setDebug: JavaMail Version 1.4.7 DEBUG: getProvider () gibt javax.mail.Provider zurück [TRANSPORT, smtp, com.sun.mail.smtp.SMTPTransport, Oracle] DEBUG SMTP: useEhlo true, useAuth true DEBUG SMTP: trying Verbindung zum Host "mail.host.com", Port 465, isSSL true javax.mail.MessagingException: Verbindung zum SMTP-Host konnte nicht hergestellt werden: mail.host.com, Port: 465; verschachtelte Ausnahme ist: javax.net.ssl.SSLHandshakeException: sun.security.validator.ValidatorException: PKIX-Pfadaufbau fehlgeschlagen: sun.security.provider.certpath.SunCertPathBuilderException: Es konnte kein gültiger Zertifizierungspfad für das angeforderte Ziel unter com.sun.mail gefunden werden .smtp.SMTPTransport.openServer (SMTPTransport.java:1961) unter com.sun.mail.smtp.SMTPTransport.protocolConnect (SMTPTransport.java:654) unter javax.mail.Service.connect (Service.java:295) unter javax. mail.Service.connect (Service.java:176) bei scam.ccChecker $ sendEmail.run (ccChecker.java:186) bei java.lang.Thread.run (Thread.java:745) Auslöser: javax.net.ssl .SSLHandshakeException: sun.security.validator.ValidatorException: Fehler beim Erstellen des PKIX-Pfads: sun.security.provider.certpath.SunCertPathBuilderException: Es wurde kein gültiger Zertifizierungspfad für das angeforderte Ziel unter sun.security.ssl.Alerts.getSSLException (Alerts.java: 192) bei sun.security.ssl.SSLSocketImpl.fatal (SSLSocketImpl.java:1937) bei sun.security.ssl.Handshaker.fatalSE (Handshaker.java : 302) bei sun.security.ssl.Handshaker.fatalSE (Handshaker.java:296) bei sun.security.ssl.ClientHandshaker.serverCertificate (ClientHandshaker.java:1478) bei sun.security.ssl.ClientHandshaker.processMessage (ClientHandshaker. java: 212) bei sun.security.ssl.Handshaker.processLoop (Handshaker.java:957) bei sun.security.ssl.Handshaker.process_record (Handshaker.java:892) bei sun.security.ssl.SSLSocketImpl.readRecord (SSLSocketImpl .java: 1050) bei sun.security.ssl.SSLSocketImpl.performInitialHandshake (SSLSocketImpl.java:1363) bei sun.security.ssl.SSLSocketImpl.startHandshake (SSLSocketImpl.java:1391) bei sun.security.ssl.SSLSocketImpl.startHands.ssl.ssl SSLSocketImpl.java:1375) unter com.sun.mail.util.SocketFetcher.configureSSLSocket (SocketFetcher.java:549) unter com.sun.mail.util.SocketFetcher.createSocket (SocketFetcher.java:354) unter com.sun.mail .util.SocketFetcher.getSocket (SocketFetcher.java:211) at com.sun.mail.smtp.SMTPTransport.openServer (SMTPTransport.java:1927) ... 5 more Auslöser: sun.security.validator.Valid atorException: PKIX-Pfaderstellung fehlgeschlagen: sun.security.provider.certpath.SunCertPathBuilderException: Es konnte kein gültiger Zertifizierungspfad zum angeforderten Ziel unter sun.security.validator.PKIXValidator.doBuild (PKIXValidator.java:387) unter sun.security.validator gefunden werden. PKIXValidator.engineValidate (PKIXValidator.java:292) bei sun.security.validator.Validator.validate (Validator.java:260) bei sun.security.ssl.X509TrustManagerImpl.validate (X509TrustManagerImpl.java:324) bei sun.security.ss .X509TrustManagerImpl.checkTrusted (X509TrustManagerImpl.java:229) bei sun.security.ssl.X509TrustManagerImpl.checkServerTrusted (X509TrustManagerImpl.java:124) bei sun.security.ssl.ClientHandshaker.server:Certificate Auslöser: sun.security.provider.certpath.SunCertPathBuilderException: Es konnte kein gültiger Zertifizierungspfad zum angeforderten Ziel unter sun.security.provider.certpath.SunCertPathBuilder.build (SunCertPathBuilder.java:145) unter sun.security.provider.certpath gefunden werden. SunCertPathBuilde r.engineBuild (SunCertPathBuilder.java:131) bei java.security.cert.CertPathBuilder.build (CertPathBuilder.java:280) bei sun.security.validator.PKIXValidator.doBuild (PKIXValidator.java:382) ... 22

kann mir jemand helfen? :

Antworten auf die Frage(4)

Ihre Antwort auf die Frage