diff options
Diffstat (limited to 'src/Mail.hs')
-rw-r--r-- | src/Mail.hs | 17 |
1 files changed, 14 insertions, 3 deletions
diff --git a/src/Mail.hs b/src/Mail.hs index bb96142..5fc2f24 100644 --- a/src/Mail.hs +++ b/src/Mail.hs @@ -1,3 +1,5 @@ +{-# LANGUAGE OverloadedStrings #-} + module Mail ( sendMail ) where @@ -11,10 +13,19 @@ import Network.Email.Sendmail (sendmail) import Utils.Either (mapLeft) -sendMail :: [Text] -> Text -> IO (Either Text ()) -sendMail mailTo body = +sendMail :: [Text] -> Text -> Text -> IO (Either Text ()) +sendMail mailTo subject message = let from = Just "no-reply@leboncoin-listener.com" - in safeSendMail from (map T.unpack $ mailTo) (T.unpack body) + in safeSendMail from (map T.unpack $ mailTo) (T.unpack $ makeBody subject message) + +makeBody :: Text -> Text -> Text +makeBody subject message = + T.concat + [ "Subject: " + , subject + , "\n\n" + , message + ] safeSendMail :: Maybe String -> [String] -> String -> IO (Either Text ()) safeSendMail from to body = |