Mail.hs 1.1 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13
{-|
Module      : Gargantext.Core.Mail
Description :
Copyright   : (c) CNRS, 2017-Present
License     : AGPL + CECILL v3
Maintainer  : team@gargantext.org
Stability   : experimental
Portability : POSIX

-}

{-# LANGUAGE OverloadedStrings #-}

14
module Gargantext.Prelude.Mail
15
  (gargMail, GargMail(..))
16 17
  where

18 19
-- import Data.Text.Internal.Lazy (Text)
import Data.Text (Text)
20 21 22 23 24 25
import Data.Maybe
import Network.Mail.SMTP hiding (htmlPart)
import Gargantext.Prelude
import Network.Mail.Mime (plainPart)


26 27 28 29 30 31 32 33 34 35 36 37
type Email = Text
type Name  = Text

data GargMail = GargMail { gm_to      :: Email
                         , gm_name    :: Maybe Name
                         , gm_subject :: Text
                         , gm_body    :: Text
                         }

-- | TODO add parameters to gargantext.ini
gargMail :: GargMail -> IO ()
gargMail (GargMail to' name subject body) = sendMail "localhost" mail
38
  where
39
    mail = simpleMail from to cc bcc subject [plainPart $ cs body]
40

41 42
    from       = Address (Just "GargTeam") "contact@gargantext.org"
    to         = [Address name to']
43 44 45 46
    cc         = []
    bcc        = []