@@ -19,8 +19,9 @@ import Network.Mail.SMTP
1919import Server.App
2020import Server.Auth.Token
2121import Control.Monad.IO.Class
22−import Network.Mail.Mime (Mail)
22+import Network.Mail.Mime (Mail, Part)
2323import Data.Text (Text, pack)
24+import qualified Data.Text.Lazy as TL
2425import Data.Text.Lazy (fromStrict)
2526
2627sendTokenVerificationEmail :: TokenVerificationCode -> Text -> App ()
@@ -30,10 +31,12 @@ sendTokenVerificationEmail code email = do
3031 (Address (Just "HSE Social Network") "noreply@hse.ru")
3132 [Address Nothing email] [] []
3233 "HSE Social Network Verification Code"
33− [plainTextPart . fromStrict . pack . show $ code]
34+ [genMail . show $ code]
3435 sendMailWithConfig mailCfg mail
35− -- sendMailWithLogin' "smtp.sendgrid.net" 25 "apikey" "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" (simpleMail (Address (Just "HSE") "foo@hse.ru") [(Address (Just "YOU") "iikostyuchenko@edu.hse.ru")] [] [] "HI" [plainTextPart "HELLO\n\nsosi"])
3636
3737sendMailWithConfig :: (MonadIO m) => MailConfig -> Mail -> m ()
3838sendMailWithConfig (MailConfig host port user pass) =
3939 liftIO . sendMailWithLogin' host (fromIntegral port) user pass
40+
41+genMail :: String -> Part
42+genMail [a, b, c, d, e, f] = htmlPart $ "<html><body style=\"font-family: sans-serif;\"> <h1> <div align=\"center\" style=\"margin-top: 20vh;\"> <a href=\"#\" style=\"font-size: 34px; font-weight: bold; display: inline-block; padding: 7px 13px 7px 13px; margin-bottom: 89px; text-decoration: underline; font-family: sans-serif; color: #555;\"> Log in </a> <br/> <div style=\"font-size: 55px; font-weight: bold; border-radius: 10px; background-color: #eee; display: inline-block; padding: 7px 13px 7px 13px; box-shadow: 0px 5px 21px #bbb; background-image: linear-gradient(#f9f9f9, #eee);\">" <> TL.pack [a, b] <> "<div style=\"display: inline-block; width: 10px;\"></div>" <> TL.pack [c, d] <> "<div style=\"display: inline-block; width: 10px;\"></div>" <> TL.pack [e, f] <> "</div></div><div align=\"center\" style=\"margin-top: 233px;\"> <a href=\"#\" style=\"text-decoration: underline; font-family: sans-serif; color: #555;font-size: 13px;\">Revoke access</a> </div></body></html>"