2022-11-08 20:16:34 +01:00
|
|
|
{-# LANGUAGE OverloadedStrings #-}
|
|
|
|
module Sender where
|
|
|
|
|
|
|
|
import Network.Mail.Mime
|
|
|
|
import Network.Mail.SMTP
|
|
|
|
import qualified Data.Text as ST
|
|
|
|
import qualified Data.Text.Lazy as LT
|
2022-11-12 16:18:11 +01:00
|
|
|
import Monad
|
2022-11-08 20:16:34 +01:00
|
|
|
|
|
|
|
|
|
|
|
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
|
2022-11-12 16:18:11 +01:00
|
|
|
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
|
2022-11-08 20:16:34 +01:00
|
|
|
where
|
|
|
|
mail = generateMail to from subj body
|
|
|
|
|