davsclaus opened a new pull request, #3174: URL: https://github.com/apache/camel-kamelets/pull/3174
Part of #3170: `mail-sink` can use STARTTLS, which most mail providers require on port 587, such as Gmail and Microsoft 365. ### The option `startTls` is a boolean. With `protocol: smtp` and `startTls: true`, it switches the connection to TLS with the STARTTLS command before logging in. - STARTTLS is also required, so sending fails when the server does not offer it, and the password is never sent in clear. - The certificate and the host name of the server are checked. - With `smtps`, the option is ignored, because that connection is TLS from the start. The option sets the JavaMail properties `mail.smtp.starttls.enable` and `mail.smtp.starttls.required` through camel-mail's `mail.` parameter prefix, so no bean is needed. `startTls` deliberately has no `default`. When it is not set, the optional placeholders drop both parameters, so the endpoint URI is exactly today's. A `default: false` would put an explicit `false` on the endpoint, and that would override STARTTLS turned on through JVM system properties or the smtp component settings, which is the likely workaround in use today. The `protocol` and `connectionPort` descriptions and the "Good to know" paragraph now say how the protocol, `startTls` and the port combine. The partial page has a table of them and a port 587 example. ### Verification Tested with Camel JBang against Mailpit (with login), and against a small proxy that behaves like `smtp.gmail.com:587`: it offers AUTH only after STARTTLS. This was checked with an EHLO against Gmail and Office 365. | Case | Result | |---|---| | `startTls: true`, server requires STARTTLS, certificate trusted | Sent; the mail is in Mailpit | | The same without trusting the certificate | Fails: `PKIX path building failed` | | The same with a wrong host name | Fails: `No subject alternative DNS name matching ...` | | Option unset, Gmail-like server, Kamelet from `main` and from this PR | Both fail the same way: no login, then `530 Must issue a STARTTLS command first` | | `startTls: true`, Gmail-like server | STARTTLS, then login, then `250 Ok: queued` | | Option unset, plain SMTP server, Kamelet from `main` and from this PR | Both send | | `startTls: false`, plain server | Sent | | `startTls: true`, plain server | Fails before any login: `STARTTLS is required but host does not support STARTTLS` | | `smtps`, unset and with `startTls: true` | Sent over TLS from the start; the option is ignored | The test trusted the self-signed certificate through a JVM trust store (`-Djavax.net.ssl.trustStore`). Setting a trust store from the Kamelet is a separate item in #3170. `./mvnw clean install` passed twice, the first time with `-DskipTests`. _Claude Code on behalf of Claus Ibsen_ 🤖 Generated with [Claude Code](https://claude.com/claude-code) -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
