Swiftpack.co -  Joannis/VaporSMTPKit as Swift Package
Swiftpack.co is a collection of thousands of indexed Swift packages. Search packages.
Joannis/VaporSMTPKit
SMTP support in Vapor 4
.package(url: "https://github.com/Joannis/VaporSMTPKit.git", from: "1.0.3")

Vapor 4 + SMTP

Add this library to Package.swift

.package(url: "https://github.com/autimatisering/VaporSMTPKit.git", from: "1.0.0")

Add the target "VaporSMTPKit" to your own target's dependencies. In Swift 5.2 manifests, this looks like the following:

.product(name: "VaporSMTPKit", package: "VaporSMTPKit"),

Setup

import VaporSMTPKit

extension SMTPCredentials {
    static var `default`: SMTPCredentials {
        return SMTPCredentials(
            hostname: "smtp.example.com",
            ssl: .startTLS(configuration: .default),
            email: "noreply@example.com",
            password: "<SECRET>"
        )
    }
}

Sending a Mail

app.get { request -> EventLoopFuture<String> in
    let email = Mail(
        from: "noreply@example.com",
        to: [
            MailUser(name: "Myself", email: "me@example.com")
        ],
        subject: "Your new mail server!",
        contentType: .plain,
        text: "You've set up mail!"
    )
    
    return request.application.sendMail(email, withCredentials: .default).map { 
        return "Check your mail!"
    }
}

GitHub

link
Stars: 14
Last commit: 15 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