diff options
Diffstat (limited to 'src/Mail.hs')
-rw-r--r-- | src/Mail.hs | 19 |
1 files changed, 10 insertions, 9 deletions
diff --git a/src/Mail.hs b/src/Mail.hs index 1b15f30..45962a5 100644 --- a/src/Mail.hs +++ b/src/Mail.hs @@ -17,17 +17,18 @@ import Utils.Either (mapLeft) sendMail :: [Text] -> Text -> Text -> IO (Either Text ()) sendMail mailTo subject body = safeSendMail (mail mailTo subject body) +safeSendMail :: Mail -> IO (Either Text ()) +safeSendMail mail = + mapLeft (T.pack . show) <$> (try (renderSendMail mail) :: IO (Either SomeException ())) + mail :: [Text] -> Text -> Text -> Mail mail mailTo subject body = - (emptyMail (address "no-reply@leboncoin-listener.com")) - { mailTo = map address mailTo - , mailParts = [[plainPart (toLazyText . fromText $ body)]] - , mailHeaders = [("Subject", subject)] - } + let fromMail = emptyMail (address "no-reply@leboncoin-listener.com") + in fromMail + { mailTo = map address mailTo + , mailParts = [[plainPart (toLazyText . fromText $ body)]] + , mailHeaders = [("Subject", subject)] + } address :: Text -> Address address mail = Address { addressName = Nothing, addressEmail = mail } - -safeSendMail :: Mail -> IO (Either Text ()) -safeSendMail mail = - mapLeft (T.pack . show) <$> (try (renderSendMail mail) :: IO (Either SomeException ())) |