{"record":{"id":"73525f5f85706bb4","repo":"SonarSource/sonarqube","slug":"unknown-type-of-smtp-secure-connection-73525f","errorCode":null,"errorMessage":"Unknown type of SMTP secure connection: ","messagePattern":"Unknown type of SMTP secure connection: ","errorType":"validation","errorClass":"SonarException","httpStatus":null,"severity":"error","filePath":"server/sonar-server-common/src/main/java/org/sonar/server/notification/email/EmailNotificationChannel.java","lineNumber":358,"sourceCode":"\n  private void configureSecureConnection(Email email) {\n    if (CI.equals(configuration.getSecureConnection(), \"SSLTLS\")) {\n      email.setSSLOnConnect(true);\n      email.setSSLCheckServerIdentity(true);\n      email.setSslSmtpPort(String.valueOf(configuration.getSmtpPort()));\n\n      // this port is not used except in EmailException message, that's why it's set with the same value than SSL port.\n      // It prevents from getting bad message.\n      email.setSmtpPort(configuration.getSmtpPort());\n    } else if (CI.equals(configuration.getSecureConnection(), \"STARTTLS\")) {\n      email.setStartTLSEnabled(true);\n      email.setStartTLSRequired(true);\n      email.setSSLCheckServerIdentity(true);\n      email.setSmtpPort(configuration.getSmtpPort());\n    } else if (CI.equals(configuration.getSecureConnection(), \"NONE\")) {\n      email.setSmtpPort(configuration.getSmtpPort());\n    } else {\n      throw new SonarException(\"Unknown type of SMTP secure connection: \" + configuration.getSecureConnection());\n    }\n  }\n\n  /**\n   * Send test email.\n   *\n   * @throws EmailException when unable to send\n   */\n  public void sendTestEmail(String toAddress, String subject, String message) throws EmailException {\n    try {\n      EmailMessage emailMessage = new EmailMessage();\n      emailMessage.setTo(toAddress);\n      emailMessage.setSubject(subject);\n      emailMessage.setPlainTextMessage(message + getServerBaseUrlFooter());\n      send(emailMessage);\n    } catch (EmailException e) {\n      LOG.debug(\"Fail to send test email to {}: {}\", toAddress, e);\n      throw e;","sourceCodeStart":340,"sourceCodeEnd":376,"githubUrl":"https://github.com/SonarSource/sonarqube/blob/184c821202192afc1c599fc912d0889b69fffa53/server/sonar-server-common/src/main/java/org/sonar/server/notification/email/EmailNotificationChannel.java#L340-L376","documentation":"EmailNotificationChannel.configureSecureConnection maps the sonar.email.secureConnection setting to JavaMail configuration, accepting only SSL, STARTTLS, or NONE. Any other value throws SonarException naming the unknown value.","triggerScenarios":"sonar.email.secureConnection set to anything other than 'SSL', 'STARTTLS', or 'NONE' (case-insensitive), e.g. 'TLS', 'ssl/tls', blank string with different meaning.","commonSituations":"Admin entering 'TLS' expecting STARTTLS; documentation from other products ('ssl_on'); typos; values migrated from older SonarQube versions.","solutions":["Set sonar.email.secureConnection to exactly SSL, STARTTLS, or NONE.","If the server needs plain TLS-on-connect, use SSL; for explicit upgrade use STARTTLS.","Restart/re-test the SMTP configuration via the 'Send test email' button after changing the value."],"exampleFix":"// before\nsonar.email.secureConnection=TLS\n// after\nsonar.email.secureConnection=STARTTLS","handlingStrategy":"validation","validationCode":"java.util.Set<String> allowed = java.util.Set.of(\"SSL\", \"STARTTLS\", \"NONE\");\nif (!allowed.contains(secureConnection.toUpperCase(java.util.Locale.ROOT))) throw new IllegalArgumentException(\"sonar.email.secureConnection must be SSL, STARTTLS or NONE\");","typeGuard":null,"tryCatchPattern":"try { mailService.sendTestEmail(); } catch (SonarException e) { if (e.getMessage().startsWith(\"Unknown type of SMTP secure connection\")) { log.error(\"Fix sonar.email.secureConnection value\"); } throw e; }","preventionTips":["Only set SSL, STARTTLS, or NONE","Note STARTTLS is the TLS upgrade option, not 'TLS'","Use the Send test email button to validate SMTP settings"],"tags":["email","smtp","configuration","enum"],"backgroundTag":"invalid-enum-value","analyzedSha":"184c821202192afc1c599fc912d0889b69fffa53","analyzedAt":"2026-09-09T12:23:51.573Z","contentChangedAt":"2026-09-09T12:23:51.573Z","schemaVersion":2},"datasetVersion":"2026-09-17T15:17:12.973Z"}