Skip to content
✉️ SMTP protocol support for the Vapor web framework.
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Type Name Latest commit message Commit time
Failed to load latest commit information.


Build Status Swift 5.0 Vapor 3 Swift Package Manager Platforms OS X | Linux

✉️ SMTP protocol support for the Vapor web framework.

This framework has dependencies only to Vapor and SwiftNIO packages. SwiftNIO support was inspired by Apple examples: Swift NIO examples.


  • Vapor provider/service
  • SwiftNIO Support
  • Text/HTML
  • Attachments
  • SSL
  • Multiple recipients & CC
  • Reply to
  • Multiple emails sent at the same time
  • BCC fields
  • TSL

Getting started

Add the dependency to Package.swift:

.package(url: "", from: "1.0.0")

Register the SMTP server configuration and the provider.

let configuration = SmtpServerConfiguration(hostname: "smtp.server",
                                            port: 465,
                                            username: "johndoe",
                                            password: "passw0rd",
                                            secure: .ssl)

try services.register(SmtpClientProvider())

Using SMTP client.

let smtpClientService = try app.make(SmtpClientService.self)

let email = Email(from: EmailAddress(address: "", name: "John Doe"),
                  to: [EmailAddress(address: "", name: "Ben Doe")],
                  subject: "The subject (text)",
                  body: "This is email body.")

smtpClientService.send(email, on: request).map { result in
    switch result {
    case .success:
        print("Email has been sent")
    case .failure(let error):
        print("Email has not been sent: \(error)")


You can use logHandler to handle and print all messages send/retrieved from email server.

smtpClientService.send(email, on: request) { message in
}.map { result in
You can’t perform that action at this time.