Guest User

Untitled

a guest
Feb 13th, 2019
146
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.44 KB | None | 0 0
  1. 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
  2. at com.sun.mail.smtp.SMTPTransport.startTLS(SMTPTransport.java:2000)
  3.  
  4. 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
  5.  
  6. Caused by: sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target
  7.  
  8. Caused by: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target
  9.  
  10. <bean id="mailSender" class="org.springframework.mail.javamail.JavaMailSenderImpl">
  11. <property name="host" value="${mail.host}"/>
  12. <property name="port" value="${mail.port}"/>
  13. <property name="username" value="${mail.username}"/>
  14. <property name="password" value="${mail.password}"/>
  15. <property name="javaMailProperties">
  16. <props>
  17. <prop key="mail.transport.protocol">${mail.transport.protocol}</prop>
  18. <prop key="mail.smtp.auth">${mail.smtp.auth}</prop>
  19. <prop key="mail.smtp.starttls.enable">${mail.smtp.starttls.enable}</prop>
  20. <prop key="mail.smtp.ssl.trust">${mail.smtp.ssl.trust}</prop>
  21. </props>
  22. </property>
  23. </bean>
  24.  
  25. mail.host=smtp.gmail.com
  26. mail.port=587
  27. mail.username=user@gmail.com
  28. mail.password=password
  29. mail.transport.protocol=smtp
  30. mail.smtp.auth=true
  31. mail.smtp.starttls.enable=true
  32. mail.smtp.ssl.trust=smtp.gmail.com
  33.  
  34. Email email = new SimpleEmail();
  35. email.setHostName("smtp.googlemail.com");
  36. email.setSmtpPort(465);
  37. email.setAuthenticator(new DefaultAuthenticator("username", "password"));
  38. email.setSSLOnConnect(true);
  39. email.setFrom("user@gmail.com");
  40. email.setSubject("TestMail");
  41. email.setMsg("This is a test mail ... :-)");
  42. email.addTo("foo@bar.com");
  43. email.send();
  44.  
  45. Properties props = new Properties();
  46. MailSSLSocketFactory socketFactory = new MailSSLSocketFactory();
  47. socketFactory.setTrustAllHosts(true);
  48. props.put("mail.imaps.ssl.socketFactory", socketFactory);
  49.  
  50. <dependency>
  51. <groupId>javax.mail</groupId>
  52. <artifactId>mail</artifactId>
  53. <version>1.5.0-b01</version>
  54. </dependency>
Add Comment
Please, Sign In to add comment