Este contenido no está disponible en el idioma seleccionado.

Chapter 39. Mail Microsoft Oauth


Since Camel 3.18.4.

The Mail Microsoft OAuth2 provides an implementation of org.apache.camel.component.mail.MailAuthenticator to authenticate IMAP/POP/SMTP connections and access to Email via Spring’s Mail support and the underlying JavaMail system.

Add the following dependency to your pom.xml for this component:

<dependency>
    <groupId>org.apache.camel</groupId>
    <artifactId>camel-mail-microsoft-oauth</artifactId>
    <version>3.20.1.redhat-00031</version>
    <!-- use the same version as your Camel core version -->
</dependency>
Copy to Clipboard Toggle word wrap

Importing camel-mail-microsoft-oauth will automatically import camel-mail component.

39.1. Microsoft Exchange Online OAuth2 Mail Authenticator IMAP sample

To use OAuth, an application must be registered with Azure Active Directory. Follow the instructions to register a new application.

Procedure

  1. Enable the application to access Exchange mailboxes via client credentials flow. For more information, see Authenticate an IMAP, POP or SMTP connection using OAuth
  2. Once everything is set up, declare and register in the registry, an instance of org.apache.camel.component.mail.MicrosoftExchangeOnlineOAuth2MailAuthenticator.
  3. For Example, in a Spring Boot application:
@BindToRegistry("auth")
public MicrosoftExchangeOnlineOAuth2MailAuthenticator exchangeAuthenticator(){
    return new MicrosoftExchangeOnlineOAuth2MailAuthenticator(tenantId, clientId, clientSecret, "jon@doe.com");
}
Copy to Clipboard Toggle word wrap
  1. Then reference it in the Camel URI as follows:
 from("imaps://outlook.office365.com:993"
                    +  "?authenticator=#auth"
                    +  "&mail.imaps.auth.mechanisms=XOAUTH2"
                    +  "&debugMode=true"
                    +  "&delete=false")
Copy to Clipboard Toggle word wrap
Volver arriba
Red Hat logoGithubredditYoutubeTwitter

Aprender

Pruebe, compre y venda

Comunidades

Acerca de la documentación de Red Hat

Ayudamos a los usuarios de Red Hat a innovar y alcanzar sus objetivos con nuestros productos y servicios con contenido en el que pueden confiar. Explore nuestras recientes actualizaciones.

Hacer que el código abierto sea más inclusivo

Red Hat se compromete a reemplazar el lenguaje problemático en nuestro código, documentación y propiedades web. Para más detalles, consulte el Blog de Red Hat.

Acerca de Red Hat

Ofrecemos soluciones reforzadas que facilitan a las empresas trabajar en plataformas y entornos, desde el centro de datos central hasta el perímetro de la red.

Theme

© 2025 Red Hat