diff options
Diffstat (limited to 'src/server/SendMail.hs')
-rw-r--r-- | src/server/SendMail.hs | 19 |
1 files changed, 9 insertions, 10 deletions
diff --git a/src/server/SendMail.hs b/src/server/SendMail.hs index e434b38..f7ba3fd 100644 --- a/src/server/SendMail.hs +++ b/src/server/SendMail.hs @@ -4,25 +4,24 @@ module SendMail ( sendMail ) where +import Control.Arrow (left) +import Control.Exception (SomeException, try) +import Data.Either (isLeft) + import Data.Text (Text) +import Data.Text.Lazy.Builder (toLazyText, fromText) import qualified Data.Text as T -import Data.Either (isLeft) import qualified Data.Text.Lazy as LT -import Data.Text.Lazy.Builder (toLazyText, fromText) - -import Control.Exception (SomeException, try) -import Control.Arrow (left) - -import qualified Network.Mail.Mime as M +import qualified MimeMail as M -import Model.Mail +import Model.Mail (Mail(Mail)) sendMail :: Mail -> IO (Either Text ()) sendMail mail = do result <- left (T.pack . show) <$> (try (M.renderSendMail . getMimeMail $ mail) :: IO (Either SomeException ())) if isLeft result - then putStrLn ("Error sending the following email:" ++ (show mail)) - else return () + then putStrLn ("Error sending the following email:" ++ (show mail) ++ "\n" ++ (show result)) + else putStrLn "OK" return result getMimeMail :: Mail -> M.Mail |