blob: bb9614211eb81191561798213f37ecdde2474f2b (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
|
module Mail
( sendMail
) where
import Data.Text (Text)
import qualified Data.Text as T
import Control.Exception (SomeException, try)
import Network.Email.Sendmail (sendmail)
import Utils.Either (mapLeft)
sendMail :: [Text] -> Text -> IO (Either Text ())
sendMail mailTo body =
let from = Just "no-reply@leboncoin-listener.com"
in safeSendMail from (map T.unpack $ mailTo) (T.unpack body)
safeSendMail :: Maybe String -> [String] -> String -> IO (Either Text ())
safeSendMail from to body =
mapLeft (T.pack . show) <$> (try (sendmail from to body) :: IO (Either SomeException ()))
|