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.
I have been struggling to send emails form within a Haskell program for a
Share
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: