Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

📧 SendGrid-powered mail backend for Vapor

License

NotificationsYou must be signed in to change notification settings

vapor-community/sendgrid

Repository files navigation

avatar

SendGrid

DocumentationTeam ChatMIT LicenseContinuous IntegrationSwift 6.0+

📧 SendGrid library for the Vapor web framework, based onSendGridKit.

Send simple emails or leverage the full capabilities ofSendGrid's V3 API.

Getting Started

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"),

Overview

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.

Using the API

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)

Error handling

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)")}

[8]ページ先頭

©2009-2025 Movatter.jp