gravitee-io / issues

Gravitee.io - API Platform - Issues
64 stars 26 forks source link

[docker] API User Registration Mail not received #2215

Closed mpays closed 5 years ago

mpays commented 5 years ago

Hi, Set up the gravitee docker environment using the docker compose project.

Issue: Email not received in the email address provided during registration.

Setting: Added the following in docker-compose-local.yml. local_managementapi: extends: file: common.yml service: managementapi ports:

Checked gravitee.log. No error printed in this log. Please let me know if there is another log file that needs to be checked to know if the mail configuration has been correctly done or not. Thanks.

mpays commented 5 years ago

Can anybody update this?

brasseld commented 5 years ago

Did you try to do some actions to send an email ? Which one ?

I just had a try and it works fine on my side...

brasseld commented 5 years ago

Ok, I get it. Please try with:

- gravitee_email_enabled=true
- gravitee_email_host=smtp.gmail.com
- gravitee_email_port=587
- gravitee_email_from=abc@mycompany.com
- gravitee_email_username=abc@mycompany.com
- gravitee_email_password=mypassword
- gravitee_email_properties_auth=true
- gravitee_email_properties_starttls.enable=true
- gravitee_email_properties_ssl.trust=smtp.gmail.com
mpays commented 5 years ago

Hi,

This is precisely what I had also done if you check my original

Setting: Added the following in docker-compose-local.yml. local_managementapi: extends: file: common.yml service: managementapi ports:

  • "9005:8083" volumes:
  • ./logs/management-api:/home/gravitee/logs links:
  • "local_mongodb:demo-mongodb"
  • "local_elasticsearch:demo-elasticsearch" environment:
  • gravitee_management_mongodb_uri=mongodb://demo-mongodb:27017/gravitee?serverSelectionTimeoutMS=5000&connectTimeoutMS=5000&socketTimeoutMS=5000
  • gravitee_analytics_elasticsearch_endpoints_0=http://demo-elasticsearch:9200
  • gravitee_email_enabled=true
  • gravitee_email_host=smtp.gmail.com
  • gravitee_email_port=587
  • gravitee_email_from=abc@mycompany.com
  • gravitee_email_username=abc@mycompany.com
  • gravitee_email_password=mypassword
  • gravitee_email_properties_auth=true
  • gravitee_email_properties_starttls_enable=true
  • gravitee_email_properties_ssl_trust=smtp.gmail.com

Checked gravitee.log. No error printed in this log. Please let me know if there is another log file that needs to be checked to know if the mail configuration has been correctly done or not. Thanks.

Or Have I missed something? Also, can you please let me know the location of the log file where we can check this in Docker?

brasseld commented 5 years ago

No it's not the same configuration.

Please check the dot . for starttls and ssltrust:

- gravitee_email_properties_starttls.enable=true
- gravitee_email_properties_ssl.trust=smtp.gmail.com
mpays commented 5 years ago

Thanks. One issue resolved, I am able to see the logs, and it is throwing this error:

09:53:42.413 [SimpleAsyncTaskExecutor-7] ERROR o.s.a.i.SimpleAsyncUncaughtExceptionHandler - Unexpected error occurred invoking async method: public void io.gravitee.management.service.impl.EmailServiceImpl.sendAsyncEmailNotification(io.gravitee.management.service.EmailNotification) io.gravitee.management.service.exceptions.TechnicalManagementException: Error while sending email notification at io.gravitee.management.service.impl.EmailServiceImpl.sendEmailNotification(EmailServiceImpl.java:106) at io.gravitee.management.service.impl.EmailServiceImpl.sendAsyncEmailNotification(EmailServiceImpl.java:113) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:498) at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:343) at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:197) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:163) at org.springframework.transaction.interceptor.TransactionAspectSupport.invokeWithinTransaction(TransactionAspectSupport.java:294) at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:98) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:185) at org.springframework.aop.interceptor.AsyncExecutionInterceptor.lambda$invoke$0(AsyncExecutionInterceptor.java:115) at java.util.concurrent.FutureTask.run(FutureTask.java:266) at java.lang.Thread.run(Thread.java:748) Caused by: org.springframework.mail.MailSendException: Mail server connection failed; nested exception is javax.mail.MessagingException: Could not connect to SMTP host: smtp.gmail.com, port: 587; nested exception is: java.net.ConnectException: Operation timed out (Connection timed out). Failed messages: javax.mail.MessagingException: Could not connect to SMTP host: smtp.gmail.com, port: 587; nested exception is: java.net.ConnectException: Operation timed out (Connection timed out) at org.springframework.mail.javamail.JavaMailSenderImpl.doSend(JavaMailSenderImpl.java:446) at org.springframework.mail.javamail.JavaMailSenderImpl.send(JavaMailSenderImpl.java:359) at org.springframework.mail.javamail.JavaMailSenderImpl.send(JavaMailSenderImpl.java:354) at io.gravitee.management.service.impl.EmailServiceImpl.sendEmailNotification(EmailServiceImpl.java:103) ... 14 common frames omitted Caused by: javax.mail.MessagingException: Could not connect to SMTP host: smtp.gmail.com, port: 587 at com.sun.mail.smtp.SMTPTransport.openServer(SMTPTransport.java:1961) at com.sun.mail.smtp.SMTPTransport.protocolConnect(SMTPTransport.java:654) at javax.mail.Service.connect(Service.java:295) at org.springframework.mail.javamail.JavaMailSenderImpl.connectTransport(JavaMailSenderImpl.java:515) at org.springframework.mail.javamail.JavaMailSenderImpl.doSend(JavaMailSenderImpl.java:435)

I did the ping (ping smtp.gmail.com inside the docker container using the sudo user

/opt/graviteeio-management-api # ping smtp.gmail.com PING smtp.gmail.com (74.125.24.109): 56 data bytes 64 bytes from 74.125.24.109: seq=0 ttl=45 time=60.970 ms 64 bytes from 74.125.24.109: seq=1 ttl=45 time=61.032 ms 64 bytes from 74.125.24.109: seq=2 ttl=45 time=60.932 ms 64 bytes from 74.125.24.109: seq=3 ttl=45 time=60.961 ms 64 bytes from 74.125.24.109: seq=4 ttl=45 time=60.823 ms

I believe the connection is fine from inside the docker. Can you let us know if there is any additional configuration to be done from inside the compose file?

mpays commented 5 years ago

Thanks. I ran the docker on a different environment and it is working fine. I am closing the ticket with the following solution:

No it's not the same configuration.

Please check the dot . for starttls and ssltrust:

- gravitee_email_properties_starttls.enable=true
- gravitee_email_properties_ssl.trust=smtp.gmail.com