Contents

MEMessageSecurityHandler

An object that digitally signs or encrypts messages the user sends and receives.

Declaration

@MainActor protocol MEMessageSecurityHandler : MEMessageDecoder, MEMessageEncoder

Overview

When users enable an extension that implements a message security handler, Mail passes incoming and outgoing message content to the extension for encryption and digital signing.

To encompass the symmetrical halves for encoding and decoding, MailKit defines two protocols that MEMessageSecurityHandler conforms to:

MEMessageEncoder

Methods that encrypt and digitally sign an email message.

MEMessageDecoder

Methods that decrypt email messages and verify digital signatures.

As the user composes a mail message, MailKit calls getEncodingStatus(for:composeContext:completionHandler:) to determine if the handler can sign or encrypt the message. The handler indicates the capabilities by providing an instance of MEOutgoingMessageEncodingStatus. Mail reflects this status in the compose window by enabling the appropriate buttons to let the user choose how to encode the message. When the user sends the message, MailKit invokes the encode(_:composeContext:completionHandler:) method, and indicates whether the user chose to encrypt or sign the message.

When MailKit needs the original message content, it invokes the handler’s decodedMessage(forMessageData:) method. This method creates an instance of MEDecodedMessage that includes the raw decoded message data and the details of who signed the message in an instance of MEMessageSecurityInformation.

To indicate that your extension contains a message security handler, add MEMessageSecurityHandler to the MEExtensionCapabilities array in the extension’s Info.plist file:

<key>NSExtensionAttributes</key>
<dict>
    <key>MEExtensionCapabilities</key>
    <array>
        <string>MEMessageSecurityHandler</string>
    </array>
</dict>

Topics

Encrypting and Signing Messages

Decrypting Messages and Verifying Signatures

Displaying Signature Details

Instance Methods