From 11fb0e03dfa09962793bf046bebbb31e61281fdf Mon Sep 17 00:00:00 2001 From: Finn Espen Gundersen Date: Thu, 24 Dec 2020 14:23:23 +0100 Subject: [PATCH] minor changes after review --- Guide/mail.markdown | 2 +- IHP/Mail.hs | 7 +++---- IHP/Mail/Types.hs | 8 ++++---- 3 files changed, 8 insertions(+), 9 deletions(-) diff --git a/Guide/mail.markdown b/Guide/mail.markdown index 9638b7d5f..b6cc92fd1 100644 --- a/Guide/mail.markdown +++ b/Guide/mail.markdown @@ -104,7 +104,7 @@ import IHP.Mail config :: ConfigBuilder config = do -- other options here, then add: - option $ GenericSMTP + option $ SMTP { host = "smtp.myisp.com" , port = 2525 , credentials = Nothing -- or Just ("myusername","hunter2") diff --git a/IHP/Mail.hs b/IHP/Mail.hs index db5d7feb3..94a5dbef2 100644 --- a/IHP/Mail.hs +++ b/IHP/Mail.hs @@ -24,8 +24,7 @@ import qualified Network.HTTP.Client import qualified Network.HTTP.Client.TLS import Text.Blaze.Html5 (Html) import qualified Text.Blaze.Html.Renderer.Text as Blaze -import qualified Data.ByteString.Lazy.Char8 as B8 -import qualified Data.Text as T +import qualified Data.Text as Text import Data.Maybe buildMail :: (BuildMail mail, ?context :: context, ConfigProvider context) => mail -> IO Mail @@ -52,10 +51,10 @@ sendWithMailServer SES { .. } mail = do sendWithMailServer SendGrid { .. } mail = do let mail' = if isJust category then mail {mailHeaders = ("X-SMTPAPI","{\"category\": \"" ++ (fromJust category) ++ "\"}") : headers} else mail - SMTP.sendMailWithLoginSTARTTLS' "smtp.sendgrid.net" 587 "apikey" (T.unpack apiKey) mail' + SMTP.sendMailWithLoginSTARTTLS' "smtp.sendgrid.net" 587 "apikey" (Text.unpack apiKey) mail' where headers = mailHeaders mail -sendWithMailServer GenericSMTP { .. } mail +sendWithMailServer IHP.Mail.Types.SMTP { .. } mail | isNothing credentials = SMTP.sendMail' host port mail | otherwise = SMTP.sendMailWithLogin' host port (fst creds) (snd creds) mail where creds = fromJust credentials diff --git a/IHP/Mail/Types.hs b/IHP/Mail/Types.hs index bc5fcffb2..6f27c2bbb 100644 --- a/IHP/Mail/Types.hs +++ b/IHP/Mail/Types.hs @@ -24,7 +24,7 @@ data MailServer = | SendGrid { apiKey :: Text , category :: Maybe Text } -- | Uses a generic SMTP for sending emails - | GenericSMTP { host :: String - , port :: PortNumber - -- (Username,Password) combination - , credentials :: Maybe (String, String)} + | SMTP { host :: String + , port :: PortNumber + -- (Username,Password) combination + , credentials :: Maybe (String, String)}