{-# LANGUAGE OverloadedStrings #-}
module Gargantext.Prelude.Mail
- (gargMail)
+ (gargMail, GargMail(..))
where
+-- import Data.Text.Internal.Lazy (Text)
+import Data.Text (Text)
import Data.Maybe
import Network.Mail.SMTP hiding (htmlPart)
import Gargantext.Prelude
import Network.Mail.Mime (plainPart)
--- | TODO add parameters
-gargMail :: IO ()
-gargMail = sendMail "localhost" mail
+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
where
- mail = simpleMail from to cc bcc subject [body]
+ mail = simpleMail from to cc bcc subject [plainPart $ cs body]
- from = Address (Just "François Rabelais") "francois.rabelais@gargantext.org"
- to = [Address (Just "Anoe") "alexandre@localhost"]
+ from = Address (Just "GargTeam") "contact@gargantext.org"
+ to = [Address name to']
cc = []
bcc = []
- subject = "email subject"
- body = plainPart "email body"