Created
April 14, 2017 20:53
-
-
Save Jim-Holmstroem/50f471351e6cd5bbed82d35324d09a48 to your computer and use it in GitHub Desktop.
haskell gmail stmp mail example
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{-# 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