# Email

The Email module collects a user's email address and can confirm email ownership by sending a one-time password (OTP) to that address.

For an overview of this module and how it works, see [Email Input](https://developer.incode.com/docs/email-input).

How you use this module depends on your integration pattern. When the app defines the steps in code, you add the module to an `IncdOnboardingFlowConfiguration` as shown below; when the flow is defined in Dashboard, you reference it by ID. See [Integration Approaches](https://developer.incode.com/docs/ios-flow-configuration).

**Availability:** All variants.

## Add Email

Add the module with `addEmail()`. The `otpVerification` parameter is optional. Call `addEmail()` with no arguments to use the default configuration.

```swift
flowConfig.addEmail(otpVerification: true)
```

## Configuration Options

Configure the module with `addEmail()`.

| Option            | Type    | Notes                                                                                                                                                                       |
| ----------------- | ------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `otpVerification` | `Bool?` | If `true`, shows OTP verification after the user enters an email address. When `nil` (the default), `addEmail` falls back to the manager flag `enableEmailOTPVerification`. |

OTP expiration and prefill are **not** configurable through the `addEmail` API: it always builds the module with no prefill and no expiration override. A flow defined in Dashboard and run by reference can carry a full OTP configuration, but the code-defined `addEmail` builder exposes only `otpVerification`.

## Result

Email delivers an `EmailAddressResult` to the `onAddEmailAddressCompleted(_:)` callback on your `IncdOnboardingDelegate`:

```swift
func onAddEmailAddressCompleted(_ result: EmailAddressResult)
```

`EmailAddressResult` fields:

- `email: String?`: The email address captured from the user; `nil` when unavailable.
- `error: IncdError?`: The error that occurred while capturing the email address, if any; otherwise, `nil`.

<br />
