Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6029931
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T04:57:40+00:00 2026-05-23T04:57:40+00:00

I have been struggling to send emails form within a Haskell program for a

  • 0

I have been struggling to send emails form within a Haskell program for a while now, tried to use HaskellMime library or something like that, but failed.
I installed HaskellNet recently and try using Haskellnet.SMTP module.
I tried sending an email with ‘sendMail’ command and get “user error(sendMail error)”. I suppose it was because the SMTP server I used needed authentication.
I took a look at ‘sendMail’ source code and ended up writing this simple main: http://hpaste.org/47841
I checked each ‘sendCommand’ command and after the AUTH command I get a “Auth success” from the SMTP server, and 250 code from the other commands, as expected in the ‘sendMail’ source code.
The problem is I don’t have any mails in my mailbox, so what am I doing wrong? The only thing I can think of, is that the mail is somewhere queued in the SMTP outgoing list and I need to flush the SMTP server, but that is not part of the ‘sendMail’ code, so I wonder…
Any help would be greatly appreciated, because I never thought it would be so hard to send an email :/
P.S. I use the exact same settings on my phone to send email with this SMTP server, same “smtp.sfr.fr”, same ID (entire address), same password; and it works: I can send mails from my phone.
Thanks in advance for the help.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T04:57:40+00:00Added an answer on May 23, 2026 at 4:57 am

    While I can’t comment on your use of HaskellNet, I’ve had great success using SMTPClient which you can grab from hackage with cabal install SMTPClient.

    I’ve included the package’s example to give you a sense of what using the library is like:

    import Network.SMTP.ClientSession
    import Network.SMTP.Client
    import Network.Socket
    import System.Time
    import System.IO
    import Data.Bits
    import Data.IORef
    
    myDomain = "example.com"
    smtpHost = "hubert.blacksapphire.com"    -- <-- Your SMTP server here
    
    -- This will send the author an email.  I don't mind!
    main = do
        now <- getClockTime
        nowCT <- toCalendarTime now
        let message = Message [
                    From [NameAddr (Just "Mr. Nobody") "nobody@example.com"],
                    To   [NameAddr (Just "Stephen Blackheath") "unprintable.distances.stephen@blacksapphire.com"],
                    Subject "I'm using SMTPClient!",
                    Date nowCT
                ]
                ("Dear Sir,\n"++
                 "It has come to my attention that this is an email.\n"++
                 "Yours sincerely,\n"++
                 "Mr. Nobody\n")
        addrs <- getAddrInfo Nothing (Just smtpHost) Nothing
        let SockAddrInet _ hostAddr = addrAddress (addrs !! 0)
            sockAddr = SockAddrInet (fromIntegral 25) hostAddr
        putStrLn $ "connecting to "++show sockAddr
        sentRef <- newIORef []
        sendSMTP' (hPutStrLn stderr) (Just sentRef) myDomain
            sockAddr [message]
        statuses <- readIORef sentRef
        -- If no exception was caught, statuses is guaranteed to be
        -- the same length as the list of input messages, therefore head won't fail here.
        case head statuses of
            Nothing     -> putStrLn "Message successfully sent"
            Just status -> putStrLn $ "Message send failed with status "++show status
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have been struggling for a while now to send an image file over
Have been struggling with Javascript closure for a while trying to wrap brain around
I have been struggling with this question for awhile now, and I haven't reached
been struggling with an issue now for a day or two. I have an
I have been struggling with this problem for a few days now and I
I have been struggling with a unit testing problem on Android for a while
I have been struggling with trying to send an email with an attachment using
I have been struggling with that for 4 days now. I have a very
I have been struggling with this for some time now scanning the net for
I have been struggling for too long a time now with a rather simple

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.