Send HTML formatted emails using Amazon's SES REST API with blaze

LTS Haskell 22.30:
Stackage Nightly 2024-07-22:
Latest on Hackage:

See all snapshots ses-html appears in

BSD-3-Clause licensed by David Johnson
Maintained by [email protected]
This version can be pinned in stack with:ses-html-,1150

Module documentation for


Hackage Hackage Dependencies Haskell Programming Language BSD3 License Build Status

Send blaze-html emails via the AWS SES API using http-streams


{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE LambdaCase #-}

module Main where

import Network.SES ( sendEmailBlaze
                   , PublicKey(..)
                   , SecretKey(..)
                   , SESResult(..)
                   , SESError
                   , Region(USEast1)

import qualified Text.Blaze.Html5 as H
import qualified Text.Blaze.Html5.Attributes as A

main :: IO ()
main = sendMail >>= \case
         Error _ -> putStrLn "There was an error :("
         Success -> putStrLn "Email sent successfully!"

sendMail :: IO SESREsult
sendMail = sendEmailBlaze publicKey secretKey region from to subject html
   publicKey = PublicKey "public key goes here"
   secretKey = SecretKey "secret key goes here"
   region    = USEast1
   from    = "[email protected]"
   to      = ["[email protected]"]
   subject = "Test Subject"
   html = H.html $ do
            H.body $ do
               H.img H.! A.src ""
               H.h1 "Html email! Hooray"