Support SMTPKitten ..< 0.2.0
Add this library to Package.swift
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:
"VaporSMTPKit"
.product(name: "VaporSMTPKit", package: "VaporSMTPKit"),
import VaporSMTPKit extension SMTPCredentials { static var `default`: SMTPCredentials { return SMTPCredentials( hostname: "smtp.example.com", ssl: .startTLS(configuration: .default), email: "noreply@example.com", password: "<SECRET>" ) } }
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!" } }
©Copyright 2023 CCF 开源发展委员会 Powered by Trustie& IntelliDE 京ICP备13000930号
Vapor 4 + SMTP
Add this library to
Package.swift
Add the target
"VaporSMTPKit"
to your own target’s dependencies. In Swift 5.2 manifests, this looks like the following:Setup
Sending a Mail