Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

<socket: 6>: Data.ByteString.hGetLine: end of file #21

Open
ivnsch opened this issue Nov 13, 2017 · 4 comments
Open

<socket: 6>: Data.ByteString.hGetLine: end of file #21

ivnsch opened this issue Nov 13, 2017 · 4 comments

Comments

@ivnsch
Copy link

ivnsch commented Nov 13, 2017

I get this error when calling sendMailWithLogin' "smtp.gmail.com" 465 "myemail@gmail.com" "password" mail

Nothing else! How do I get more information about the error? Any idea what can be causing it?

@nixorn
Copy link

nixorn commented Feb 16, 2018

+1 to this issue.
Problem somewhere in deep of https://github.com/jhickner/smtp-mail/blob/master/Network/Mail/SMTP.hs#L255

@ColtHands
Copy link

+1 here

@ColtHands
Copy link

ColtHands commented Jun 27, 2018

This problem also occured with packages like HaskellNet and mime-mail.

For me problem was that my smtp server had a SSL connection security and i don't think this package has a SSL solution.

Below is the working code:

{-# OPTIONS -fno-warn-missing-signatures #-}
{-# LANGUAGE OverloadedStrings #-}

module SendMail (mailer) where

import System.IO
import Network.Mail.Mime
import Network.HaskellNet.SMTP
import Network.HaskellNet.SMTP.SSL
import Network.HaskellNet.Auth
import qualified Data.Text as T
import qualified Data.ByteString as S
import qualified Data.ByteString.Lazy as B

server       = "smtp.yandex.com"
port         = 465
authType     = LOGIN
from         = ""
to           = ""
subject      = "Network.HaskellNet.SMTP Test :)"
plainBody    = "Hello world!"
htmlBody     = "<html><head></head><body><h1>Hello <i>world!</i></h1></body></html>"
attachments  = [] -- example [("application/octet-stream", "/path/to/file1.tar.gz), ("application/pdf", "/path/to/file2.pdf")]

mailer = doSMTPSSL server $ \conn -> do
    putStrLn "usr: "
    username <- getLine
    putStrLn "pass: "
    password <-getLine
    print $ username
    print $ password
    authSuccess <- authenticate authType username password conn
    if authSuccess
        then
            sendMimeMail to from subject plainBody htmlBody [] conn
        else putStrLn "Authentication failed."

The key here is HaskellNet-SSL package wich provides SSL connection and mime-mail that constructs the mails themselves.

@chshersh
Copy link

Is it possible to add SSL support to smpt-mail package? I discovered the following Reddit post and SSL support was requested 5 years ago:

Apparently, the person who wanted to send PR didn't manage to do this...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants