Haskell Sendgrid v3 API Library
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
src/Network/SendGridV3
tests
.gitignore
.travis.yml Add missing env matrix Jan 20, 2018
ChangeLog.md
LICENSE
README.md Example code compiles. Sep 16, 2018
Setup.hs
sendgrid-v3.cabal
stack.yaml Bump dependencies and stack resolver versions Aug 16, 2018

README.md

SendGrid-v3

Build Status

A library for accessing the v3 SendGrid API in Haskell.

{-# LANGUAGE OverloadedStrings #-}

import Data.List.NonEmpty (fromList)
import Network.SendGridV3.Api

sendGridApiKey :: ApiKey
sendGridApiKey = ApiKey "SG..."

testMail :: Mail () ()
testMail =
  let to = personalization $ fromList [MailAddress "john@example.com" "John Doe"]
      from = MailAddress "jane@example.com" "Jane Smith"
      subject = "Email Subject"
      content = fromList [mailContentText "Example Content"]
  in mail [to] from subject content

main :: IO ()
main = do
  -- Simple Send
  statusCode <- sendMail sendGridApiKey testMail
  print statusCode
  -- Send with further options
  statusCode' <- sendMail sendGridApiKey (testMail { _mailSendAt = Just 1516468000 })
  print statusCode'

Test Setup

echo "export SENDGRID_API_KEY='SG.YOURKEY'" > sendgrid.env
echo "export SENDGRID_TEST_MAIL='target.email.address@doe.com' > sendgrid.env
source ./sendgrid.env