VaporResend is a wrapper for the SwiftResend package, designed for use with the Vapor framework to communicate with the Resend email sending platform API.
Add the dependency to your Package.swift:
dependencies: [
...
.package(url: "https://github.com/hsharghi/vapor-resend.git", from: "1.0.0")
],
targets: [
.target(name: "App", dependencies: [
.product(name: "VaporResend", package: "vapor-resend"),
]),
Provide the RESEND_API_KEY
environment variable for authentication.
Import VaporResend
modules and configure your routes:
import Vapor
import VaporResend
func routes(_ app: Application) throws {
app.get("send") { req async throws -> String in
let id = try await req.resend.emails.send(email: .init(from: .init(email: "hadi@domain.com", name: "Hadi"),
to: [.init(email: "john@apple.com")],
subject: "Sending email from Vapor",
text: "Email sent using ResendVapor"))
return id
}
}
For full SDK documentation check out SwiftResend Package.