Swiftpack.co - globulus/swiftui-mail-view as Swift Package

Swiftpack.co is a collection of thousands of indexed Swift packages. Search packages.
See all packages published by globulus.
globulus/swiftui-mail-view 1.0.1
Send mail from SwiftUI!
⭐️ 24
🕓 2 years ago
iOS
.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: ["[email protected]"],
                                                 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: 24
Last commit: 2 years ago
Advertisement: IndiePitcher.com - Cold Email Software for Startups

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