No explicit mention is made anywhere in the documentation about TLS or even SSL, so perhaps not? Some libraries I've come across specifically mention that they don't support TLS or SSL. Being relatively new to this part of Haskell, what is the most standard library the community uses for email that supports modern protocols such as those used by GMail? Thanks. On Mon, Apr 18, 2016 at 2:49 PM, Alex Feldman-Crough <alex@fldcr.com> wrote:
Does the library support TLS? Does it have to be configured differently? It sounds like a negotiation error to me. On Mon, Apr 18, 2016 at 2:43 PM David Escobar <davidescobar1976@gmail.com> wrote:
Hi everyone, I'm trying to use the *Network.Mail.SMTP* library to send email:
*{-# LANGUAGE OverloadedStrings #-}*
*module Main where*
*import Control.Exception*
*import qualified Data.Text as T* *import qualified Data.Text.Lazy as LT* *import Network.Mail.SMTP*
*main :: IO ()* *main = do* * sendEmail (“Person sender”, “sender@somewhere.com <sender@somewhere.com>”)* * [(“Person recipient“, “recipient@somewhere.com <recipient@somewhere.com>”)]* * "Test email"* * "Some message goes here."*
*sendEmail :: (T.Text, T.Text) -> [(T.Text, T.Text)] -> T.Text -> T.Text -> IO ()* *sendEmail (fromName, fromEmail) toAddresses subject' body' = do* * let toNameAddrs = map (\(toName, toEmail) -> Address (Just toName) toEmail) toAddresses* * msg = simpleMail (Address (Just fromName) fromEmail)* * toNameAddrs* * []* * []* * subject'* * [ plainTextPart $ LT.fromStrict body' ]* * result <- try $ sendMailWithLogin' "smtp.gmail.com <http://smtp.gmail.com>"* * 465 -- SSL port* * “sender_login”* * “sender_password”* * msg :: IO (Either SomeException ())* * case result of* * Left e -> putStrLn $ "Exception caught: " ++ (displayException e)* * Right _ -> putStrLn "Sent email successfully."*
The program compiles, but when I run it, I get:
*Exception caught: <socket: 49>: Data.ByteString.hGetLine: end of file*
I tried using the TLS port of 587, but then I just get an authentication failure. Am I using the wrong library or is it just the wrong configuration. Thanks. _______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe
-- Alex Feldman Crough 602 573-9588
Right, you need to STARTTLS and upgrade to a secure connection before trying to authenticate, but smtp-mail will not take care of this for you. You could do it manually, using the tls package, or you could try smtp-mail-ng[1][2]. Alex [1] https://github.com/avieth/smtp-mail-ng [2] https://hackage.haskell.org/package/smtp-mail-ng-0.1.0.1 On Mon, Apr 18, 2016 at 6:36 PM, David Escobar <davidescobar1976@gmail.com> wrote:
No explicit mention is made anywhere in the documentation about TLS or even SSL, so perhaps not? Some libraries I've come across specifically mention that they don't support TLS or SSL. Being relatively new to this part of Haskell, what is the most standard library the community uses for email that supports modern protocols such as those used by GMail? Thanks.
On Mon, Apr 18, 2016 at 2:49 PM, Alex Feldman-Crough <alex@fldcr.com> wrote:
Does the library support TLS? Does it have to be configured differently? It sounds like a negotiation error to me. On Mon, Apr 18, 2016 at 2:43 PM David Escobar <davidescobar1976@gmail.com> wrote:
Hi everyone, I'm trying to use the *Network.Mail.SMTP* library to send email:
*{-# LANGUAGE OverloadedStrings #-}*
*module Main where*
*import Control.Exception*
*import qualified Data.Text as T* *import qualified Data.Text.Lazy as LT* *import Network.Mail.SMTP*
*main :: IO ()* *main = do* * sendEmail (“Person sender”, “sender@somewhere.com <sender@somewhere.com>”)* * [(“Person recipient“, “recipient@somewhere.com <recipient@somewhere.com>”)]* * "Test email"* * "Some message goes here."*
*sendEmail :: (T.Text, T.Text) -> [(T.Text, T.Text)] -> T.Text -> T.Text -> IO ()* *sendEmail (fromName, fromEmail) toAddresses subject' body' = do* * let toNameAddrs = map (\(toName, toEmail) -> Address (Just toName) toEmail) toAddresses* * msg = simpleMail (Address (Just fromName) fromEmail)* * toNameAddrs* * []* * []* * subject'* * [ plainTextPart $ LT.fromStrict body' ]* * result <- try $ sendMailWithLogin' "smtp.gmail.com <http://smtp.gmail.com>"* * 465 -- SSL port* * “sender_login”* * “sender_password”* * msg :: IO (Either SomeException ())* * case result of* * Left e -> putStrLn $ "Exception caught: " ++ (displayException e)* * Right _ -> putStrLn "Sent email successfully."*
The program compiles, but when I run it, I get:
*Exception caught: <socket: 49>: Data.ByteString.hGetLine: end of file*
I tried using the TLS port of 587, but then I just get an authentication failure. Am I using the wrong library or is it just the wrong configuration. Thanks. _______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe
-- Alex Feldman Crough 602 573-9588
_______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe
Thanks Alex. I'll start looking into that. On Mon, Apr 18, 2016 at 3:43 PM, Alexander Vieth <aovieth@gmail.com> wrote:
Right, you need to STARTTLS and upgrade to a secure connection before trying to authenticate, but smtp-mail will not take care of this for you. You could do it manually, using the tls package, or you could try smtp-mail-ng[1][2].
Alex
[1] https://github.com/avieth/smtp-mail-ng [2] https://hackage.haskell.org/package/smtp-mail-ng-0.1.0.1
On Mon, Apr 18, 2016 at 6:36 PM, David Escobar <davidescobar1976@gmail.com
wrote:
No explicit mention is made anywhere in the documentation about TLS or even SSL, so perhaps not? Some libraries I've come across specifically mention that they don't support TLS or SSL. Being relatively new to this part of Haskell, what is the most standard library the community uses for email that supports modern protocols such as those used by GMail? Thanks.
On Mon, Apr 18, 2016 at 2:49 PM, Alex Feldman-Crough <alex@fldcr.com> wrote:
Does the library support TLS? Does it have to be configured differently? It sounds like a negotiation error to me. On Mon, Apr 18, 2016 at 2:43 PM David Escobar < davidescobar1976@gmail.com> wrote:
Hi everyone, I'm trying to use the *Network.Mail.SMTP* library to send email:
*{-# LANGUAGE OverloadedStrings #-}*
*module Main where*
*import Control.Exception*
*import qualified Data.Text as T* *import qualified Data.Text.Lazy as LT* *import Network.Mail.SMTP*
*main :: IO ()* *main = do* * sendEmail (“Person sender”, “sender@somewhere.com <sender@somewhere.com>”)* * [(“Person recipient“, “recipient@somewhere.com <recipient@somewhere.com>”)]* * "Test email"* * "Some message goes here."*
*sendEmail :: (T.Text, T.Text) -> [(T.Text, T.Text)] -> T.Text -> T.Text -> IO ()* *sendEmail (fromName, fromEmail) toAddresses subject' body' = do* * let toNameAddrs = map (\(toName, toEmail) -> Address (Just toName) toEmail) toAddresses* * msg = simpleMail (Address (Just fromName) fromEmail)* * toNameAddrs* * []* * []* * subject'* * [ plainTextPart $ LT.fromStrict body' ]* * result <- try $ sendMailWithLogin' "smtp.gmail.com <http://smtp.gmail.com>"* * 465 -- SSL port* * “sender_login”* * “sender_password”* * msg :: IO (Either SomeException ())* * case result of* * Left e -> putStrLn $ "Exception caught: " ++ (displayException e)* * Right _ -> putStrLn "Sent email successfully."*
The program compiles, but when I run it, I get:
*Exception caught: <socket: 49>: Data.ByteString.hGetLine: end of file*
I tried using the TLS port of 587, but then I just get an authentication failure. Am I using the wrong library or is it just the wrong configuration. Thanks. _______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe
-- Alex Feldman Crough 602 573-9588
_______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe
Alex, unfortunately I get compiler errors when adding the *smtp-mail-ng* library (I'm using Stack for my dependency management/builds). Not sure if I'm doing something wrong on my end, but it seems to be something in the library itself. * /private/var/folders/kg/p_frph3n0d71yfmvn553s4rh0000gn/T/stack69375/smtp-mail-ng-0.1.0.2/Network/Mail/SMTP/SMTP.hs:201:3:* * Couldn't match type ‘Context’ with ‘IO Context’* * Expected type: SystemRNG -> IO Context* * Actual type: SystemRNG -> Context* * The function ‘contextNew’ is applied to three arguments,* * its type is ‘backend0 -> params0 -> m0 Context’,* * it is specialized to ‘Handle* * -> ClientParams -> SystemRNG -> Context’* * In a stmt of a 'do' block: contextNew handle params rng* * In the expression:* * do { rng <- (createEntropyPool >>= return . cprgCreate) ::* * IO SystemRNG;* * certStore <- getSystemCertificateStore;* * let params = tlsClientParams hostname certStore;* * contextNew handle params rng }* On Mon, Apr 18, 2016 at 6:15 PM, David Escobar <davidescobar1976@gmail.com> wrote:
Thanks Alex. I'll start looking into that.
On Mon, Apr 18, 2016 at 3:43 PM, Alexander Vieth <aovieth@gmail.com> wrote:
Right, you need to STARTTLS and upgrade to a secure connection before trying to authenticate, but smtp-mail will not take care of this for you. You could do it manually, using the tls package, or you could try smtp-mail-ng[1][2].
Alex
[1] https://github.com/avieth/smtp-mail-ng [2] https://hackage.haskell.org/package/smtp-mail-ng-0.1.0.1
On Mon, Apr 18, 2016 at 6:36 PM, David Escobar < davidescobar1976@gmail.com> wrote:
No explicit mention is made anywhere in the documentation about TLS or even SSL, so perhaps not? Some libraries I've come across specifically mention that they don't support TLS or SSL. Being relatively new to this part of Haskell, what is the most standard library the community uses for email that supports modern protocols such as those used by GMail? Thanks.
On Mon, Apr 18, 2016 at 2:49 PM, Alex Feldman-Crough <alex@fldcr.com> wrote:
Does the library support TLS? Does it have to be configured differently? It sounds like a negotiation error to me. On Mon, Apr 18, 2016 at 2:43 PM David Escobar < davidescobar1976@gmail.com> wrote:
Hi everyone, I'm trying to use the *Network.Mail.SMTP* library to send email:
*{-# LANGUAGE OverloadedStrings #-}*
*module Main where*
*import Control.Exception*
*import qualified Data.Text as T* *import qualified Data.Text.Lazy as LT* *import Network.Mail.SMTP*
*main :: IO ()* *main = do* * sendEmail (“Person sender”, “sender@somewhere.com <sender@somewhere.com>”)* * [(“Person recipient“, “recipient@somewhere.com <recipient@somewhere.com>”)]* * "Test email"* * "Some message goes here."*
*sendEmail :: (T.Text, T.Text) -> [(T.Text, T.Text)] -> T.Text -> T.Text -> IO ()* *sendEmail (fromName, fromEmail) toAddresses subject' body' = do* * let toNameAddrs = map (\(toName, toEmail) -> Address (Just toName) toEmail) toAddresses* * msg = simpleMail (Address (Just fromName) fromEmail)* * toNameAddrs* * []* * []* * subject'* * [ plainTextPart $ LT.fromStrict body' ]* * result <- try $ sendMailWithLogin' "smtp.gmail.com <http://smtp.gmail.com>"* * 465 -- SSL port* * “sender_login”* * “sender_password”* * msg :: IO (Either SomeException ())* * case result of* * Left e -> putStrLn $ "Exception caught: " ++ (displayException e)* * Right _ -> putStrLn "Sent email successfully."*
The program compiles, but when I run it, I get:
*Exception caught: <socket: 49>: Data.ByteString.hGetLine: end of file*
I tried using the TLS port of 587, but then I just get an authentication failure. Am I using the wrong library or is it just the wrong configuration. Thanks. _______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe
-- Alex Feldman Crough 602 573-9588
_______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe
quoth David Escobar <davidescobar1976@gmail.com>
No explicit mention is made anywhere in the documentation about TLS or even SSL, so perhaps not? Some libraries I've come across specifically mention that they don't support TLS or SSL. Being relatively new to this part of Haskell, what is the most standard library the community uses for email that supports modern protocols such as those used by GMail? Thanks.
I'm not going to guess what the community is up to, but it seems to me like the least novel way to get there would be an SSL connection to port 465, using HsOpenSSL, and use the library you were already using for SMTP. I do that, essentially, though with home rolled stuff for various not very interesting reasons. So I haven't tried these two packages, but I can assure you that the principle works with gmail. If your SMTP package won't accept some kind of generic I/O channel and insists on making and using its own socket connection, then you'll need something else. Ideally, it would provide pure functions for SMTP parsing and protocol interpretation, and you could do the I/O stuff yourself via whatever channel you wish, but that pure/io structural division seems surprisingly rare among Haskell network application packages. Donn
Thanks, that makes sense. Out of curiosity, which one do you use with HsOpenSSL? On Mon, Apr 18, 2016 at 4:23 PM, Donn Cave <donn@avvanta.com> wrote:
quoth David Escobar <davidescobar1976@gmail.com>
No explicit mention is made anywhere in the documentation about TLS or even SSL, so perhaps not? Some libraries I've come across specifically mention that they don't support TLS or SSL. Being relatively new to this part of Haskell, what is the most standard library the community uses for email that supports modern protocols such as those used by GMail? Thanks.
I'm not going to guess what the community is up to, but it seems to me like the least novel way to get there would be an SSL connection to port 465, using HsOpenSSL, and use the library you were already using for SMTP.
I do that, essentially, though with home rolled stuff for various not very interesting reasons. So I haven't tried these two packages, but I can assure you that the principle works with gmail.
If your SMTP package won't accept some kind of generic I/O channel and insists on making and using its own socket connection, then you'll need something else. Ideally, it would provide pure functions for SMTP parsing and protocol interpretation, and you could do the I/O stuff yourself via whatever channel you wish, but that pure/io structural division seems surprisingly rare among Haskell network application packages.
Donn _______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe
quoth David Escobar <davidescobar@ieee.org>
Thanks, that makes sense. Out of curiosity, which one do you use with HsOpenSSL?
[... where I said ...]
I do that, essentially, though with home rolled stuff for various not very interesting reasons. So I haven't tried these two packages,
"Home rolled" means I wrote my own SMTP protocol software, and my own OpenSSL wrapper. I haven't tried HsOpenSSL and don't know anything about it - want to be clear about that! Donn
Oh ok, my misunderstanding. I didn't realized you had done all that! On Mon, Apr 18, 2016 at 6:53 PM, Donn Cave <donn@avvanta.com> wrote:
quoth David Escobar <davidescobar@ieee.org>
Thanks, that makes sense. Out of curiosity, which one do you use with HsOpenSSL?
[... where I said ...]
I do that, essentially, though with home rolled stuff for various not very interesting reasons. So I haven't tried these two packages,
"Home rolled" means I wrote my own SMTP protocol software, and my own OpenSSL wrapper. I haven't tried HsOpenSSL and don't know anything about it - want to be clear about that!
Donn _______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe
participants (4)
-
Alexander Vieth -
David Escobar -
David Escobar -
Donn Cave