SonarQube version 10.3.0.82913 deployed via ZIP in LXC container running AlmaLinux 9
I want to configure SonarQube to use my SMTP server (postfix) to send mails. While it works fine to run something like
mail [email protected]
on the same host that runs SonarQube (which uses IP based authentication configured with MSMTP), the SonarQube UI immediatly reacts with
Configuration invalid: please double check SMTP host, port, login and password.
when sending a test mail.
So I looked in the log files:
2024.01.28 20:46:00 TRACE web[AY1RrGxDL0X8xJ4wAAA/][o.s.s.n.e.EmailNotificationChannel] Sending email: This is a test message from SonarQube.__Mail sent from: http://sonarqube.example.com
[...]
2024.01.28 20:46:00 INFO web[AY1RrGxDL0X8xJ4wAAA/][javax.mail] JavaMail version 1.6.2
2024.01.28 20:46:00 INFO web[AY1RrGxDL0X8xJ4wAAA/][javax.mail] successfully loaded resource: /META-INF/javamail.default.address.map
2024.01.28 20:46:00 DEBUG web[AY1RrGxDL0X8xJ4wAAA/][javax.activation] MailcapCommandMap: createDataContentHandler for text/plain
2024.01.28 20:46:00 DEBUG web[AY1RrGxDL0X8xJ4wAAA/][javax.activation] search DB #1
2024.01.28 20:46:00 DEBUG web[AY1RrGxDL0X8xJ4wAAA/][javax.activation] got content-handler
2024.01.28 20:46:00 DEBUG web[AY1RrGxDL0X8xJ4wAAA/][javax.activation] class com.sun.mail.handlers.text_plain
2024.01.28 20:46:00 DEBUG web[AY1RrGxDL0X8xJ4wAAA/][javax.mail] getProvider() returning javax.mail.Provider[TRANSPORT,smtp,com.sun.mail.smtp.SMTPTransport,Oracle]
2024.01.28 20:46:01 DEBUG web[AY1RrGxDL0X8xJ4wAAA/][com.sun.mail.smtp] need username and password for authentication
2024.01.28 20:46:01 DEBUG web[AY1RrGxDL0X8xJ4wAAA/][com.sun.mail.smtp] protocolConnect returning false, host=mail.example.com, user=sonarqube, password=<null>
2024.01.28 20:46:01 DEBUG web[AY1RrGxDL0X8xJ4wAAA/][com.sun.mail.smtp] useEhlo true, useAuth true
2024.01.28 20:46:01 DEBUG web[AY1RrGxDL0X8xJ4wAAA/][com.sun.mail.smtp] trying to connect to host "mail.example.com", port 465, isSSL false
2024.01.28 20:46:01 DEBUG web[AY1RrGxDL0X8xJ4wAAA/][c.s.mail.util.socket] getSocket, host mail.example.com, port 465, prefix mail.smtp, useSSL false
2024.01.28 20:46:01 TRACE web[AY1RrGxDL0X8xJ4wAAA/][c.s.mail.util.socket] create socket: prefix mail.smtp, localaddr null, localport 0, host mail.example.com, port 465, connection timeout 30000, timeout 30000, socket factory sun.security.ssl.SSLSocketFactoryImpl@1e2e4d41, useSSL false
2024.01.28 20:46:01 TRACE web[AY1RrGxDL0X8xJ4wAAA/][c.s.mail.util.socket] set socket read timeout 30000
2024.01.28 20:46:01 TRACE web[AY1RrGxDL0X8xJ4wAAA/][c.s.mail.util.socket] connecting...
2024.01.28 20:46:01 TRACE web[AY1RrGxDL0X8xJ4wAAA/][c.s.mail.util.socket] connection failed
java.net.ConnectException: connection refused
at java.base/sun.nio.ch.Net.pollConnect(Native Method)
at java.base/sun.nio.ch.Net.pollConnectNow(Net.java:672)
at java.base/sun.nio.ch.NioSocketImpl.timedFinishConnect(NioSocketImpl.java:549)
at java.base/sun.nio.ch.NioSocketImpl.connect(NioSocketImpl.java:597)
at java.base/java.net.SocksSocketImpl.connect(SocksSocketImpl.java:327)
at java.base/java.net.Socket.connect(Socket.java:633)
at com.sun.mail.util.SocketFetcher.createSocket(SocketFetcher.java:357)
at com.sun.mail.util.SocketFetcher.getSocket(SocketFetcher.java:217)
at com.sun.mail.smtp.SMTPTransport.openServer(SMTPTransport.java:2175)
at com.sun.mail.smtp.SMTPTransport.protocolConnect(SMTPTransport.java:740)
at javax.mail.Service.connect(Service.java:388)
at javax.mail.Service.connect(Service.java:246)
at javax.mail.Service.connect(Service.java:195)
at javax.mail.Transport.send0(Transport.java:254)
at javax.mail.Transport.send(Transport.java:124)
at org.apache.commons.mail.Email.sendMimeMessage(Email.java:1459)
at org.apache.commons.mail.Email.send(Email.java:1496)
at org.sonar.server.notification.email.EmailNotificationChannel.send(EmailNotificationChannel.java:227)
at org.sonar.server.notification.email.EmailNotificationChannel.sendTestEmail(EmailNotificationChannel.java:329)
[...]
2024.01.28 20:46:01 DEBUG web[AY1RrGxDL0X8xJ4wAAA/][o.s.s.n.e.EmailNotificationChannel] Fail to send test email to [email protected]: {}
org.apache.commons.mail.EmailException: Sending the email to the following server failed : mail.example.com:465
at org.apache.commons.mail.Email.sendMimeMessage(Email.java:1469)
at org.apache.commons.mail.Email.send(Email.java:1496)
at org.sonar.server.notification.email.EmailNotificationChannel.send(EmailNotificationChannel.java:227)
at org.sonar.server.notification.email.EmailNotificationChannel.sendTestEmail(EmailNotificationChannel.java:329)
[...]
Caused by: com.sun.mail.util.MailConnectException: Couldn't connect to host, port: mail.example.com, 465; timeout 30000
at com.sun.mail.smtp.SMTPTransport.openServer(SMTPTransport.java:2209)
at com.sun.mail.smtp.SMTPTransport.protocolConnect(SMTPTransport.java:740)
at javax.mail.Service.connect(Service.java:388)
at javax.mail.Service.connect(Service.java:246)
at javax.mail.Service.connect(Service.java:195)
at javax.mail.Transport.send0(Transport.java:254)
at javax.mail.Transport.send(Transport.java:124)
at org.apache.commons.mail.Email.sendMimeMessage(Email.java:1459)
... 148 common frames omitted
Caused by: java.net.ConnectException: connection refused
at java.base/sun.nio.ch.Net.pollConnect(Native Method)
at java.base/sun.nio.ch.Net.pollConnectNow(Net.java:672)
at java.base/sun.nio.ch.NioSocketImpl.timedFinishConnect(NioSocketImpl.java:549)
at java.base/sun.nio.ch.NioSocketImpl.connect(NioSocketImpl.java:597)
at java.base/java.net.SocksSocketImpl.connect(SocksSocketImpl.java:327)
at java.base/java.net.Socket.connect(Socket.java:633)
at com.sun.mail.util.SocketFetcher.createSocket(SocketFetcher.java:357)
at com.sun.mail.util.SocketFetcher.getSocket(SocketFetcher.java:217)
at com.sun.mail.smtp.SMTPTransport.openServer(SMTPTransport.java:2175)
... 155 common frames omitted
I tried using port 587 with STARTTLS, 465 with SSL and 25 without encryption - same error. I tried using IP based authentication (without username and password) as well as username and password.
I noticed that the log says protocolConnect returning false, host=mail.example.com, user=sonarqube
but the username is [email protected]
and not just sonarqube
.
What does protocolConnect returning false
mean?
Why does the log say isSSL false
and useSSL false
when it should use a SSL connection on port 465?
The postfix logs say absolutly nothing about any connection attempt even on highest log level. I tried using telnet to connect to port 25 on the mail server and the log shows this, but nothing about SonarQube’s connection attempt.
The postfix host’s firewall allows traffic on port 25, 465 and 587. The SonarQube host’s firewall does not block outgoing traffic.
It is very noticeable that the UI reacts very fast (within 144 ms refering to my browser) with the error message. So it runs definitely not into a timeout. Has to be corrupted config, DNS resolve issue or firewall, I think. Since my AlmaLinux LXC container is a pretty minimal setup, I am thinking of missing dependencies as well. Are there any? I just noticed that even which
was missing which kind of silently killed another program.
Am I missing something? Can not be that hard right?
[WEBINAR]
AI-Enhanced, Sonar Assured: Boost Developer Productivity and Improve Code Security in your SDLC - October 16
Register Now