I know it must be, probably, a very simple question, but I'm stucked at this for many hours I didn't find the problem after lots of research on internet.
I started a jhipster project, and now I'm trying to configure a e-mail server to use for send registration e-mails to my new users. So I edited the 2 configuration files that exist in the project:
../src/test/resources/config/application.yml
../src/main/resources/config/application.yml
In each one of these I added the following lines under "Spring: mail:"
host: smtp.gmail.com
port: 25
user: xxx@gmail.com
password: xxx
protocol: smtp
tls: true
auth: true
from: xxx@gmail.com
Then I tried to make a new registration and didn't work the mail confirmation, I also tried to run a test, calling explicitly the function "sendEmail" from the "mailService", it also didn't work. Someone knows why? Am I making some configuration mistake? There is something else I should make?
Adding the asked info about logs:
Usually this is the log that I get when I run the test which calls the sendMail function:
[DEBUG] org.portotech.perdigao.config.AsyncConfiguration - Creating Async Task Executor<br>
[DEBUG] org.portotech.perdigao.config.MetricsConfiguration - Registering JVM gauges<br>
[DEBUG] org.portotech.perdigao.config.CacheConfiguration - No cache<br>
[WARN] org.portotech.perdigao.Application - No Spring profile configured, running with default configuration<br>
[DEBUG] org.portotech.perdigao.config.MailConfiguration - Configuring mail server<br>
[INFO] org.portotech.perdigao.config.ThymeleafConfiguration - loading non-reloadable mail messages resources<br>
[DEBUG] org.portotech.perdigao.config.DatabaseConfiguration - Configuring Mongeez<br>
[DEBUG] org.portotech.perdigao.service.MailService - Send e-mail[multipart 'false' and html 'false'] to 'xxx@gmail.com' with subject 'test' and content=test<br>
[INFO] org.portotech.perdigao.config.CacheConfiguration - Remove Cache Manager metrics<br>
[INFO] org.portotech.perdigao.config.CacheConfiguration - Closing Cache Manager<br>
Disconnected from the target VM, address: '127.0.0.1:51831', transport: 'socket'<br>
Process finished with exit code 0
So, the email wasn't sent, but I got no error message. After you posted the comment, I opened my IDE again (Intellij) to copy the log to post here and got the following log:
[DEBUG] org.portotech.perdigao.config.AsyncConfiguration - Creating Async Task Executor<br>
[DEBUG] org.portotech.perdigao.config.MetricsConfiguration - Registering JVM gauges<br>
[DEBUG] org.portotech.perdigao.config.CacheConfiguration - No cache<br>
[WARN] org.portotech.perdigao.Application - No Spring profile configured, running with default configuration<br>
[DEBUG] org.portotech.perdigao.config.MailConfiguration - Configuring mail server<br>
[INFO] org.portotech.perdigao.config.ThymeleafConfiguration - loading non-reloadable mail messages resources<br>
[DEBUG] org.portotech.perdigao.config.DatabaseConfiguration - Configuring Mongeez<br>
[DEBUG] org.portotech.perdigao.service.MailService - Send e-mail[multipart 'false' and html 'false'] to 'xxx@gmail.com' with subject 'test' and content=test<br>
[WARN] org.portotech.perdigao.service.MailService - E-mail could not be sent to user 'xxx@gmail.com', exception is: Mail server connection failed; nested exception is javax.mail.MessagingException: Connection error (java.net.NoRouteToHostException: No route to host). Failed messages: javax.mail.MessagingException: Connection error (java.net.NoRouteToHostException: No route to host)<br>
[INFO] org.portotech.perdigao.config.CacheConfiguration - Remove Cache Manager metrics<br>
[INFO] org.portotech.perdigao.config.CacheConfiguration - Closing Cache Manager
Then I executed again, and never got that message again, about the NoRouteToHostException, the log is like the first I posted. That's really weird =/. Anyway, i did a ping to smtp.gmail.com and it is ok.