[web-devel] Sending email

Jeremy Shaw jeremy at n-heptane.com
Thu Aug 19 19:42:27 EDT 2010


Hello,

There are several pieces I have experience with.

One option is the SMTPClient package:

http://hackage.haskell.org/package/SMTPClient-1.0.3

It now includes a simple wrapper for sending mail via a smarthost,

http://hackage.haskell.org/packages/archive/SMTPClient/1.0.3/doc/html/Network-SMTP-Simple.html

At one point in time I worked on a MIME library for parsing and  
composing MIME messages. It tries to use the type system to enforce  
some level of correctness. It has types for representing MIME  
messages, and parsing attachments. But he composition module does not  
yet encode attachments:

http://src.seereason.com/haskell-mime/

The compose module includes a wrapper function to call sendmail.

http://src.seereason.com/haskell-mime/Text/MIME/Compose.hs

Instead of converting text/html to text/plain, perhaps you want to the  
input to be markdown, which can be converted to text/html or text/ 
plain ?

There is also the issue of templating. I think the requirements of  
email templates are different from HTML templates. I am fine with  
having my HTML templates be type-checked and compiled into the  
application. But, for many uses of email, that does not make sense. If  
I want to send an email to my list every day (or week) I am not going  
to want to recompile the app everytime. I am going to want the email  
to come from a file on the disk or a textarea or something. That also  
seems to mean that the information which can be inserted into the  
template is rather static. There is going to be a list of available  
fields, such as first name, last name, etc.. Unlike html templates,  
runtime checking of the template is not really a big issue. I am going  
to type up my message, and then hit 'preview' and see what it looks  
like and see an templating errors.

So, in summary, here are the features I would like:

  - runtime templates
  - support for smarthosts and local sendmail
  - the ability to create the message via markdown and convert it to  
text/plain and/or text/html
  - the ability to create MIME attachments

Also I would like to have opt-in/opt-out features. Similar to how  
mailman and other listserv things work. You can sign up for a list via  
a form or via email, and then you get a confirmation email with a link  
in it. Each messages sent can then include an unsubscribe link.

Obviously, the opt-in/opt-out stuff is not required for all uses. And  
it is really a library that builds on top of the core email  
functionality -- it does not need to be included by default.  
Especially since that starts incorporating html/http/web framework/ 
database stuff, and people are going to want something that works with  
their particular system.

And now that I think of it, the template solution should probably be a  
separate layer as well.

- jeremy

p.s. I will look at the patches to web-routes soon, I swear!


On Aug 19, 2010, at 1:43 PM, Michael Snoyman wrote:

> Hey all,
>
> I'm wondering what people do in general for sending email,  
> especially from web apps. So far, I've written some basic modules in  
> my apps that wrap around the sendmail executable on the system. Are  
> there packages on Hackage that people would recommend?
>
> As long as I'm bringing this up, I think I nice email system would  
> offer built in support for creating multipart messages. Bonus points  
> would be to automatically create a text/plain version from an HTML  
> version. If no one knows of prior art on this, I might try to  
> implement it as a module in Yesod.
>
> Michael
> _______________________________________________
> web-devel mailing list
> web-devel at haskell.org
> http://www.haskell.org/mailman/listinfo/web-devel



More information about the web-devel mailing list