aboutsummaryrefslogtreecommitdiff
path: root/src/SendMail.hs
blob: 0e1f91d13dd1de46b6eb207d371a1ffb41d4eaae (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
{-# LANGUAGE OverloadedStrings #-}

module SendMail
  ( sendMail
  ) where

import Data.Text (Text)
import qualified Data.Text as T
import Data.Text.Lazy (fromStrict)

import Network.Mail.Mime

import Logger

sendMail :: Text -> Text -> Text -> Text -> IO ()
sendMail to from subject body = do
  Logger.info $
    T.concat
      [ "Sending mail to "
      , to
      , " with subject “"
      , subject
      , "” and body “"
      , body
      , "”"
      ]
  renderSendMail (simpleMail' (address to) (address from) subject (fromStrict body))

address :: Text -> Address
address email =
  Address
    { addressName = Nothing
    , addressEmail = email
    }