]> Git — Sourcephile - gargantext.git/blob - src/Gargantext/Prelude/Mail.hs
[Type] Instance FlowLists
[gargantext.git] / src / Gargantext / Prelude / Mail.hs
1 {-|
2 Module : Gargantext.Core.Mail
3 Description :
4 Copyright : (c) CNRS, 2017-Present
5 License : AGPL + CECILL v3
6 Maintainer : team@gargantext.org
7 Stability : experimental
8 Portability : POSIX
9
10 -}
11
12 {-# LANGUAGE OverloadedStrings #-}
13
14 module Gargantext.Prelude.Mail
15 (gargMail, GargMail(..))
16 where
17
18 -- import Data.Text.Internal.Lazy (Text)
19 import Data.Text (Text)
20 import Data.Maybe
21 import Network.Mail.SMTP hiding (htmlPart)
22 import Gargantext.Prelude
23 import Network.Mail.Mime (plainPart)
24
25
26 type Email = Text
27 type Name = Text
28
29 data GargMail = GargMail { gm_to :: Email
30 , gm_name :: Maybe Name
31 , gm_subject :: Text
32 , gm_body :: Text
33 }
34
35 -- | TODO add parameters to gargantext.ini
36 gargMail :: GargMail -> IO ()
37 gargMail (GargMail to' name subject body) = sendMail "localhost" mail
38 where
39 mail = simpleMail from to cc bcc subject [plainPart $ cs body]
40
41 from = Address (Just "GargTeam") "contact@gargantext.org"
42 to = [Address name to']
43 cc = []
44 bcc = []
45
46