Skip to content
dev
Go to file
Code

Latest commit

- Update ghc in CI to 8.10.2
- Limit CI deployments to ghc 8.10.2
22f55f9 1

Git stats

Files

Permalink
Failed to load latest commit information.
Type
Name
Latest commit message
Commit time
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

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
import Control.Lens ((^.))
import Network.Wreq (responseStatus, statusCode)

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
  -- Send an email, overriding options as needed
  eResponse <- sendMail sendGridApiKey (testMail { _mailSendAt = Just 1516468000 })
  case eResponse of
    Left httpException -> error $ show httpException
    Right response -> print (response ^. responseStatus . 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

About

Haskell Sendgrid v3 API Library

Resources

License

Packages

No packages published
You can’t perform that action at this time.