SwiftUI wrapper of MessageUI.

Always be sure to call MailComposeView.canSendMail() and MessageComposeView.canSendText() in-line to confirm that you can actually use them on that device. And graphical glitches may occur if you don’t include the .ignoresSafeArea() view modifier.

It’s generally best to use them in a .sheet() modifier, but the code below is just for the sake of example.



// This will return false if the device cannot use Apple Mail.
if MailComposeView.canSendMail() {
        .init(subject: "Subject",
              toRecipients: [
                  "[email protected]"
              ccRecipients: nil,
              bccRecipients: nil,
              body: "This is an example email body.",
              bodyIsHTML: false,
              preferredSendingEmailAddress: nil)
} else {
    // Here you can tell the user the issue, or maybe launch the URL scheme to open the default mail app (which wouldn't be Apple Mail).
    Text("Mail cannot be sent from your device.")


if MessageComposeView.canSendText() {
        .init(recipients: [
              subject: "This is an MMS subject line, but it won't be inlcuded if the device doesn't have them enabled.",
              body: "This is an SMS text body.")
} else {
    // Here you can tell the user the issue.
    Text("Text messages cannot be sent from your device.")


View Github