Hello, i'm working in Grails and i got a error when i try to send a mail.
This is the error.
server connection failed; nested exception is javax.mail.MessagingException: Could not connect to SMTP host: smtp.gmail.com, port: 465 (javax.net.ssl.SSLException: java.lang.RuntimeException: Unexpected error: java.security.InvalidAlgorithmParameterException: the trustAnchors parameter must be non-empty). Failed messages: javax.mail.MessagingException: Could not connect to SMTP host: smtp.gmail.com, port: 465 (javax.net.ssl.SSLException: java.lang.RuntimeException: Unexpected error: java.security.InvalidAlgorithmParameterException: the trustAnchors parameter must be non-empty)
CODE CONTROLLER
try{
log.info("Segundo mensaje")
ByteArrayOutputStream bytes = (ByteArrayOutputStream)pdfRenderingService.render(template: "/cotizador/print", model:[ordenTransmisionInstance:ordenTransmisionInstance,total:params.total,imagen:imagen.bytes])
mailService.sendMail {
multipart true
to params.email
subject "Correo de cotización de productos"
body "A continaución se adjunta un archivo con la información de cotización."
attachBytes "cotizacion.pdf", "application/pdf", bytes.toByteArray()
}
}catch (Exception e){
log.info("Tercer mensaje" + e.getMessage())
flash.message = message(code: "send.email.fail.error", default: "Ha ocurrido un error por favor intente nuevamente.")
}
Config.groovy
grails {
mail {
host = "smtp.gmail.com"
port = 465
username = "******"
password = "******"
props = ["mail.smtp.auth":"true",
"mail.smtp.socketFactory.port":"465",
"mail.smtp.socketFactory.class":"javax.net.ssl.SSLSocketFactory",
"mail.smtp.socketFactory.fallback":"false"]
}
}