Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/joannis/vaporsmtpkit
SMTP support in Vapor 4
https://github.com/joannis/vaporsmtpkit
Last synced: 19 days ago
JSON representation
SMTP support in Vapor 4
- Host: GitHub
- URL: https://github.com/joannis/vaporsmtpkit
- Owner: Joannis
- Created: 2020-02-21T19:35:06.000Z (over 4 years ago)
- Default Branch: master
- Last Pushed: 2024-04-22T13:12:33.000Z (7 months ago)
- Last Synced: 2024-10-13T14:44:44.993Z (about 1 month ago)
- Language: Swift
- Size: 16.6 KB
- Stars: 58
- Watchers: 1
- Forks: 11
- Open Issues: 8
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Vapor 4 + SMTP
Add this library to `Package.swift`
```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:```swift
.product(name: "VaporSMTPKit", package: "VaporSMTPKit"),
```## Setup
```swift
import VaporSMTPKitextension SMTPCredentials {
static var `default`: SMTPCredentials {
return SMTPCredentials(
hostname: "smtp.example.com",
ssl: .startTLS(configuration: .default),
email: "[email protected]",
password: ""
)
}
}
```### Sending a Mail
```swift
app.get { request -> EventLoopFuture 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!"
}
}
```