Swiftpack.co -  globulus/swiftui-mail-view as Swift Package
Swiftpack.co is a collection of thousands of indexed Swift packages. Search packages.
globulus/swiftui-mail-view
Send mail from SwiftUI!
.package(url: "https://github.com/globulus/swiftui-mail-view.git", from: "1.0.1")

SwiftUIMailView

The MailView allows you to send mail from SwiftUI. You can:

  • 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.

The end result looks like this:

in action

Recipe

Check out this recipe for in-depth description of the component and its code. Check out SwiftUIRecipes.com for more SwiftUI recipes!

Sample usage

struct MailViewTest: View {
   @State private var mailData = ComposeMailData(subject: "A subject",
                                                 recipients: ["i.love@swiftuirecipes.com"],
                                                 message: "Here's a message",
                                                 attachments: [AttachmentData(data: "Some text".data(using: .utf8)!,
                                                                              mimeType: "text/plain",
                                                                              fileName: "text.txt")
                                                 ])
   @State private var showMailView = false

    var body: some View {
        Button(action: {
            showMailView.toggle()
        }) {
            Text("Send mail")
        }
        .disabled(!MailView.canSendMail)
        .sheet(isPresented: $showMailView) {
            MailView(data: $mailData) { result in
                print(result)
            }
        }
    }
}

Installation

This component is distrubuted as a Swift package.

GitHub

link
Stars: 3
Last commit: 5 weeks ago

Ad: Job Offers

iOS Software Engineer @ Perry Street Software
Perry Street Software is Jack’d and SCRUFF. We are two of the world’s largest gay, bi, trans and queer social dating apps on iOS and Android. Our brands reach more than 20 million members worldwide so members can connect, meet and express themselves on a platform that prioritizes privacy and security. We invest heavily into SwiftUI and using Swift Packages to modularize the codebase.

Swiftpack is being maintained by Petr Pavlik | @ptrpavlik | @swiftpackco | API