<!--
{
  "availability" : [
    "macOS: 12.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "MailKit",
  "identifier" : "/documentation/MailKit/MEComposeSessionHandler",
  "metadataVersion" : "0.1.0",
  "role" : "Protocol",
  "symbol" : {
    "kind" : "Protocol",
    "modules" : [
      "MailKit"
    ],
    "preciseIdentifier" : "c:objc(pl)MEComposeSessionHandler"
  },
  "title" : "MEComposeSessionHandler"
}
-->

# MEComposeSessionHandler

An object that participates in the composition of mail messages, and annotates recipient tokens.

```
@MainActor protocol MEComposeSessionHandler : NSObjectProtocol
```

## Overview

When the user composes a message, MailKit requests a compose session handler object from your extension. MailKit uses this handler in the following ways:

- To inform it when the compose session begins and ends
- To add status annotations for email addresses that the user enters into the To, Cc, and Bcc fields
- To display a custom popover in the compose window
- To include custom headers in an outgoing message
- To confirm that an outgoing message is ready for delivery

Each of the items in the list above corresponds to methods that the handler implements.

To indicate that your extension contains a compose session handler, add `MEComposeSessionHandler` to the <doc://com.apple.documentation/documentation/BundleResources/Information-Property-List/NSExtension/NSExtensionAttributes/MEExtensionCapabilities> array in the extension’s `Info.plist` file:

```swift
<key>NSExtensionAttributes</key>
<dict>
    <key>MEExtensionCapabilities</key>
    <array>
        <string>MEComposeSessionHandler</string>
    </array>
</dict>
```

## Topics

### Handling Compose Sessions

[`MEComposeSession`](/documentation/MailKit/MEComposeSession)

An object that represents a single mail compose window.

[`-  mailComposeSessionDidBegin:`](/documentation/MailKit/MEComposeSessionHandler/mailComposeSessionDidBegin(_:))

Informs the handler when the user opens a compose window.

[`-  mailComposeSessionDidEnd:`](/documentation/MailKit/MEComposeSessionHandler/mailComposeSessionDidEnd(_:))

Informs the handler when the user closes a compose window.

[`MEComposeSessionError`](/documentation/MailKit/MEComposeSessionError)

An error that indicates the compose session is in an erroneous state.

### Annotating Email Address Tokens

[`-  session:annotateAddressesWithCompletionHandler:`](/documentation/MailKit/MEComposeSessionHandler/annotateAddressesForSession(_:completion:))

Indicates whether recipients in the compose window are valid or not.

[`MEAddressAnnotation`](/documentation/MailKit/MEAddressAnnotation)

An object that indicates the validity of an email address.

### Extending the Compose Window Interface

[`-  viewControllerForSession:`](/documentation/MailKit/MEComposeSessionHandler/viewController(for:))

Provides a custom view controller to display as part of the compose window.

### Adding Custom Headers

[`-  additionalHeadersForSession:`](/documentation/MailKit/MEComposeSessionHandler/additionalHeaders(for:))

Provides custom headers to include in the outgoing message.

### Approving Message Delivery

[`-  session:canSendMessageWithCompletionHandler:`](/documentation/MailKit/MEComposeSessionHandler/allowMessageSendForSession(_:completion:))

Confirms that the message is ready for delivery.

## Relationships

### Inherits From

[`NSObjectProtocol`](/documentation/ObjectiveC/NSObjectProtocol)

---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)