> ## Documentation Index
> Fetch the complete documentation index at: https://docs.apollodeploy.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Send emails with Java

> Send a transactional email with the official Apollo Signal Java SDK

The Java 17 SDK provides a class-based client and uses
`https://api.signal.apollodeploy.com` by default.

Before you start, [create an API key](/signal/create-an-api-key) with **Emails: Send** permission
and [verify the From domain](/signal/add-a-domain).

<Steps>
  <Step title="Install the SDK">
    For Gradle:

    ```groovy theme={"dark"}
    dependencies {
        implementation 'com.apollodeploy.signal:signal-sdk-java:4.0.1'
    }
    ```

    For Maven:

    ```xml theme={"dark"}
    <dependency>
      <groupId>com.apollodeploy.signal</groupId>
      <artifactId>signal-sdk-java</artifactId>
      <version>4.0.1</version>
    </dependency>
    ```
  </Step>

  <Step title="Store your API key">
    Set `SIGNAL_API_KEY` in the server environment or secret manager.
  </Step>

  <Step title="Send an email">
    ```java theme={"dark"}
    import com.apollodeploy.signal.sdk.ApolloSignalApiClient;
    import com.apollodeploy.signal.sdk.models.Types.SendEmailRequest;
    import java.util.List;
    import java.util.Map;

    var config = new ApolloSignalApiClient.Config()
            .defaultHeaders(Map.of(
                    "Authorization",
                    "Bearer " + System.getenv("SIGNAL_API_KEY")));

    try (var signal = new ApolloSignalApiClient(config)) {
        var request = new SendEmailRequest();
        request.from = "auth@mail.company.com";
        request.to = List.of("alex@example.com");
        request.subject = "Reset your password";
        request.text = "Use the secure link in your account to choose a new password.";

        var email = signal.emails().sendEmail(request);
        System.out.println(email.id);
    }
    ```
  </Step>
</Steps>

<Note>
  Close the client when its lifecycle ends. Reuse one client for the lifetime of a service instead
  of creating it for every request.
</Note>

<CardGroup cols={2}>
  <Card title="Kotlin" icon="code" href="/signal/send-with/send-with-kotlin">
    Use the coroutine-based Kotlin SDK.
  </Card>

  <Card title="All SDKs" icon="code" href="/signal/send-with/sdk-overview">
    Compare every supported language and framework.
  </Card>
</CardGroup>
