I wanted to write a utility script in Haskell last night that sent some emails using my gmail account.
However, gmail requires a SSL/TLS connection to their SMTP server, and I couldn't figure out how to accomplish this with HaskellNet's sendMail
.
How could I have done this with HaskellNet? Or is there a different SMTP library I should use?
This is quite an old post now, but just thought I'd pop an answer up in case somebody stumbles across it looking for SSL/TLS support for IMAP/SMTP. I've put a library up on Hackage which adds TLS support to HaskellNet's mail functionality by doing pretty much what hammar suggested in his answer.
You can find the library here: http://hackage.haskell.org/package/HaskellNet-SSL along with sample code here.
From a quick glance at the docs, I noticed connectStream
, which lets you use an already-opened stream, as well as the fact that all the functions work on BSStream s => s
rather than a plain Handle
. I'm guessing you could use this with the tls
package to write a BSStream
instance for TLSCtx a
(or a newtype) to allow you to use a TLS/SSL connection with HaskellNet's sendMail
.
I don't have any experience with either package, but it looks like it might be possible.
Have you considered configuring sendmail with GMail and using smtp-mail to talk to sendmail
?
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With