Skip to content

Instantly share code, notes, and snippets.

@pbrisbin
Created October 17, 2014 18:37
Show Gist options
  • Select an option

  • Save pbrisbin/3dcfc1bd640e8ccf7d2e to your computer and use it in GitHub Desktop.

Select an option

Save pbrisbin/3dcfc1bd640e8ccf7d2e to your computer and use it in GitHub Desktop.
SendGrid test via Haskell
{-# LANGUAGE OverloadedStrings #-}
module Main where
import Network.Mail.Mime
import Network.Mail.SMTP
import qualified Data.Text.Lazy as TL
-- Get from e.g. `heroku config`
username = ""
password = ""
recipient = Address (Just "name") "email"
main :: IO ()
main = do
let mail = simpleMail' recipient from subject body
sendMailWithLogin' "smtp.sendgrid.net" 587 username password mail
where
from = Address (Just "SendGrid Test") "noreply@example.com"
subject = "Sent via SendGrid using Haskell"
body = TL.unlines
[ "Hi there,"
, ""
, "Did you get this?"
, ""
, "Thanks,"
, "SendGrid Test"
]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment