<!--
{
  "availability" : [
    "macOS: 12.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "MailKit",
  "identifier" : "/documentation/MailKit/MEComposeSessionHandler/allowMessageSendForSession(_:completion:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "MailKit"
    ],
    "preciseIdentifier" : "c:objc(pl)MEComposeSessionHandler(im)session:canSendMessageWithCompletionHandler:"
  },
  "title" : "allowMessageSendForSession(_:completion:)"
}
-->

# allowMessageSendForSession(_:completion:)

Confirms that the message is ready for delivery.

```
optional func allowMessageSendForSession(_ session: MEComposeSession, completion: @escaping ((any Error)?) -> Void)
```

## Parameters

`session`

The session that represents the properties of the message in the compose window.

`completion`

A block you call after determining if the message is ready for delivery.

## Discussion

> Important:
> You can call this method from synchronous code using a completion handler, as shown on this page, or you can call it as an asynchronous method that has the following declaration:
> 
> ```swift
> optional func allowMessageSendForSession(_ session: MEComposeSession) async throws
> ```
> 
> For information about concurrency and asynchronous code in Swift, see <doc://com.apple.documentation/documentation/Swift/calling-objective-c-apis-asynchronously>.

MailKit gives your compose session handler an opportunity to confirm that a message is ready for delivery. If the message is ready for delivery and needs no further attention, call the completion handler and pass `nil`.

If there’s an issue with the message’s content and you want to prompt the user, call the completion handler and pass an error that contains a localized description of the reason the message isn’t ready. For example, the following code calls the completion handler with an error if a recipient uses the domain `@example.com`.

```swift
enum ComposeSessionError: LocalizedError {
    case invalidRecipientDomain
    
    var errorDescription: String? {
        switch self {
        case .invalidRecipientDomain:
            return "example.com is not a valid recipient domain"
        }
    }
}

func allowMessageSendForSession(_ session: MEComposeSession, completion: @escaping (Error?) -> Void) {
    // Confirm none of the recipients use @example.com.
    if session.mailMessage.allRecipientAddresses.contains(where: { $0.hasSuffix("@example.com")}) {
        completion(ComposeSessionError.invalidRecipientDomain)
    } else {
        completion(nil)
    }
}
```

> Note:
> The alert that the system displays to the user is advisory only. The user can choose to send the message regardless of the issue your compose session handler indicates.

---

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)