some error handling and cleanup that comes with it

This commit is contained in:
nerf van nerfingen 2022-11-12 16:18:11 +01:00
parent 99ab66b419
commit 616fc48990
7 changed files with 91 additions and 31 deletions

View file

@ -5,14 +5,15 @@ import Network.Mail.Mime
import Network.Mail.SMTP
import qualified Data.Text as ST
import qualified Data.Text.Lazy as LT
import Monad
generateMail :: ST.Text -> ST.Text -> ST.Text -> LT.Text -> Mail
generateMail to from subj = simpleMail' (Address Nothing to) (Address Nothing from) subj
-- domain -> Username -> password -> To -> From -> Subject -> Body
send :: String -> String -> String -> ST.Text -> ST.Text -> ST.Text -> LT.Text -> IO ()
send domain user pass to from subj body = sendMailWithLoginTLS domain user pass mail
send :: (MonadIO m) => String -> String -> String -> ST.Text -> ST.Text -> ST.Text -> LT.Text -> m ()
send domain user pass to from subj body = liftIO $ sendMailWithLoginTLS domain user pass mail
where
mail = generateMail to from subj body