Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

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

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 VaporSMTPKit

extension 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!"
}
}
```