ejbca-ce icon indicating copy to clipboard operation
ejbca-ce copied to clipboard

Problem with mail configuration

Open jhondari1989 opened this issue 3 years ago • 1 comments

I find myself configuring the email to be able to send notifications, for which I am using a GMAIL email, it has IMAP and POP enabled. To run the docker container I use the following code: docker run -it --rm -p 80:8080 -p 443:8443 -h localhost -e "SMTP_DESTINATION=smtp.gmail.com" -e "SMTP_DESTINATION_PORT=465" -e "[email protected]" -e "[email protected]" -e "SMTP_PASSWORD=mypassword" keyfactor/ejbca-ce.

When I generate a new certificate with the option to send the notification by email, the server log gives me two errors:

2022-08-02 04:24:31,062+0000 ERROR [org.ejbca.util.mail.MailSender] (default task-4) Unable to send email: : javax.mail.MessagingException: Got bad greeting from SMTP host: smtp.gmail.com, port: 465, response: [EOF] at [email protected]//com.sun.mail.smtp.SMTPTransport.openServer(SMTPTransport.java:2198) at [email protected]//com.sun.mail.smtp.SMTPTransport.protocolConnect(SMTPTransport.java:722) at [email protected]//javax.mail.Service.connect(Service.java:364) at [email protected]//javax.mail.Service.connect(Service.java:222) at [email protected]//javax.mail.Service.connect(Service.java:171) at ... at [email protected]//org.xnio.XnioWorker$WorkerThreadFactory$1$1.run(XnioWorker.java:1282) at java.base/java.lang.Thread.run(Unknown Source)

2022-08-02 04:24:31,067+0000 ERROR [org.ejbca.core.ejb.ra.EndEntityManagementSessionBean] (default task-4) Error sending notification to user newuser with email [email protected].: org.ejbca.util.mail.MailException: Failed to hand over email to JavaMail. at deployment.ejbca.ear//org.ejbca.util.mail.MailSender.sendMailOrThrow(MailSender.java:78) at deployment.ejbca.ear.ejbca-ejb.jar//org.ejbca.core.ejb.ra.EndEntityManagementSessionBean.sendNotification(EndEntityManagementSessionBean.java:2149) at deployment.ejbca.ear.ejbca-ejb.jar//org.ejbca.core.ejb.ra.EndEntityManagementSessionBean.addUser(EndEntityManagementSessionBean.java:486) at deployment.ejbca.ear.ejbca-ejb.jar//org.ejbca.core.ejb.ra.EndEntityManagementSessionBean.addUser(EndEntityManagementSessionBean.java:275) at ... at [email protected]//org.xnio.XnioWorker$WorkerThreadFactory$1$1.run(XnioWorker.java:1282) at java.base/java.lang.Thread.run(Unknown Source)

First of all, Thanks

jhondari1989 avatar Aug 02 '22 04:08 jhondari1989

"response: [EOF]" sounds almost like a non-TLS connection trying to connect to a TLS port. Is port 465 TLS on your mail server? By default I think the destination port should be non-TLS, like a normal port 25. Can you try that?

There is also a TLS variable, but I see the default value is true already. It may mean STARTTLS is enabled only though. SMTP_TLS_ENABLED=true

primetomas avatar Aug 09 '22 11:08 primetomas

"response: [EOF]" sounds almost like a non-TLS connection trying to connect to a TLS port. Is port 465 TLS on your mail server? By default I think the destination port should be non-TLS, like a normal port 25. Can you try that?

There is also a TLS variable, but I see the default value is true already. It may mean STARTTLS is enabled only though. SMTP_TLS_ENABLED=true

It worked on port 587 and a unique application key must be created in GMAIL for it to work properly.

jhondari1989 avatar Sep 06 '22 00:09 jhondari1989

Thanks for the update. I'll close this issue as fixed.

primetomas avatar Sep 19 '22 12:09 primetomas