18
May
2021
Send mail in SwiftUI
swiftui mail mailview MFMailComposeViewController messageui messageReading time: 2 min
This recipe shows how to send mail from SwiftUI. You'll build a MailView
by wrapping MessageUI's MFMailComposeViewController
in a UIViewControllerRepresentable
. You'll be able to:
- Determine if you can send mail or not.
- Pass subject, message and recipients to the view via a binding.
- Attach files to the email.
- Receive success or failure result after sending the email.
Search our recipes
Check out the companion apps!
Our free companion app and XCode Extension brings 100+ SwiftUI recipes right at your fingertips! Get a preview of it in the Online Companion.
Have a recipe for us?
Get in touch and let's grow the cookbook together!