<!--
{
  "availability" : [
    "iOS: 3.0.0 -",
    "iPadOS: 3.0.0 -",
    "macCatalyst: 13.1.0 -",
    "visionOS: 1.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "MessageUI",
  "identifier" : "/documentation/MessageUI/MFMailComposeViewControllerDelegate/mailComposeController(_:didFinishWith:error:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "Message UI"
    ],
    "preciseIdentifier" : "c:objc(pl)MFMailComposeViewControllerDelegate(im)mailComposeController:didFinishWithResult:error:"
  },
  "title" : "mailComposeController(_:didFinishWith:error:)"
}
-->

# mailComposeController(_:didFinishWith:error:)

Tells the delegate that the user wants to dismiss the mail composition view.

```
optional func mailComposeController(_ controller: MFMailComposeViewController, didFinishWith result: MFMailComposeResult, error: (any Error)?)
```

## Parameters

`controller`

The view controller object that manages the mail composition view.

`result`

The result of the user’s action.

`error`

If an error occurred, this parameter contains an error object with information about the type of failure.

## Discussion

Your implementation of this method should dismiss the mail composition view. Implementation of this method is optional, but expected.

If the user has opted to send the email created by this interface, that email should be queued in the user’s Mail program by the time this method is called. If an error occurred while queueing the email message, the `error` parameter contains an error object that indicates the type of failure that occurred.

---

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)