Skip to content

Instantly share code, notes, and snippets.

@Jim-Holmstroem
Created April 14, 2017 20:53
Show Gist options
  • Save Jim-Holmstroem/50f471351e6cd5bbed82d35324d09a48 to your computer and use it in GitHub Desktop.
Save Jim-Holmstroem/50f471351e6cd5bbed82d35324d09a48 to your computer and use it in GitHub Desktop.
haskell gmail stmp mail example
{-# LANGUAGE OverloadedStrings #-}
import Network.HaskellNet.IMAP.SSL
import Network.HaskellNet.SMTP.SSL as SMTP
import Network.HaskellNet.Auth (AuthType(LOGIN))
import qualified Data.ByteString.Char8 as B
username = "[email protected]"
password = "<password>"
recipient = "[email protected]"
smtpTest = doSMTPSTARTTLS "smtp.gmail.com" $ \c -> do
authSucceed <- SMTP.authenticate LOGIN username password c
if authSucceed
then sendPlainTextMail recipient username subject body c
else print "Authentication error."
where subject = "Test message"
body = "This is a test message"
main :: IO ()
main = do
smtpTest
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment