Swiftpack.co - Joannis/VaporSMTPKit as Swift Package

Swiftpack.co is a collection of thousands of indexed Swift packages. Search packages.
See all packages published by Joannis.
Joannis/VaporSMTPKit 1.0.4
SMTP support in Vapor 4
⭐️ 54
🕓 45 weeks ago
macOS
.package(url: "https://github.com/Joannis/VaporSMTPKit.git", from: "1.0.4")

Vapor 4 + SMTP

Add this library to Package.swift

.package(url: "https://github.com/Joannis/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: "[email protected]",
            password: "<SECRET>"
        )
    }
}

Sending a Mail

app.get { request -> EventLoopFuture<String> in
    let email = Mail(
        from: "[email protected]",
        to: [
            MailUser(name: "Myself", email: "[email protected]")
        ],
        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: 54
Last commit: 4 weeks ago
Advertisement: IndiePitcher.com - Cold Email Software for Startups

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