- Notifications
You must be signed in to change notification settings - Fork30
📧 SendGrid-powered mail backend for Vapor
License
vapor-community/sendgrid
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Repository files navigation
📧 SendGrid library for the Vapor web framework, based onSendGridKit.
Send simple emails or leverage the full capabilities ofSendGrid's V3 API.
Use the SPM string to easily include the dependendency in yourPackage.swift
file
.package(url:"https://github.com/vapor-community/sendgrid.git", from:"6.0.0"),
and add it to your target's dependencies:
.product(name:"SendGrid",package:"sendgrid"),
Warning
Make sure that theSENDGRID_API_KEY
variable is set in your environment.This can be set in the Xcode scheme, or specified in yourdocker-compose.yml
, or even provided as part of aswift run
command.A missing API key will result in a fatal error.
You can use all of the available parameters here to build yourSendGridEmail
.
Usage in a route closure would be as followed:
import SendGridletemail=SendGridEmail(…)tryawait req.sendgrid.client.send(email: email)
If the request to the API failed for any reason aSendGridError
is thrown, which has anerrors
property that contains an array of errors returned by the API.
Simply ensure you catch errors thrown like any other throwing function.
import SendGriddo{tryawait req.sendgrid.client.send(email: email)}catchlet error asSendGridError{ req.logger.error("\(error.errors)")}
About
📧 SendGrid-powered mail backend for Vapor
Topics
Resources
License
Uh oh!
There was an error while loading.Please reload this page.
Stars
Watchers
Forks
Uh oh!
There was an error while loading.Please reload this page.
Contributors14
Uh oh!
There was an error while loading.Please reload this page.