Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Haskell: SMTP over SSL

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?

like image 529
rampion Avatar asked Nov 07 '11 12:11

rampion


3 Answers

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.

like image 140
danielpwright Avatar answered Oct 12 '22 16:10

danielpwright


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.

like image 29
hammar Avatar answered Oct 12 '22 17:10

hammar


Have you considered configuring sendmail with GMail and using smtp-mail to talk to sendmail?

like image 1
Wilfred Hughes Avatar answered Oct 12 '22 17:10

Wilfred Hughes