added SMTPResource to exyus

2008-02-11 @ 00:41#

i checked into the source code a new resource class to exyus this evening. the new SMTPResource class handles the details of accepting POSTed values and using them to send an SMTP email message. this first implementation is very rudimentary (no support for CC/BCC, etc.) but it gets things started. i'll refine it over the next few days and then roll it up into the weekly builds for next weekend.

the code for declaring an instance class is pretty simple. here's my current test version:

using System;
using Exyus.Web;

namespace Exyus.Samples
{
    [UriPattern(@"/sendmail/\.xcs")]
    [MediaTypes("application/x-www-form-urlencoded", "text/xml")]
    class SendMail : SMTPResource
    {
        public SendMail()
        {
            this.AllowPost = true;
            this.ContentType = "text/xml";
            this.DocumentsFolder = "~/documents/sendmail/";
            this.PostLocationUri = "/sendmail/thankyou";
            this.RedirectOnPost = true;
            this.XHtmlNodes = new string[] {"//body"};
        }
    }

    [UriPattern(@"/sendmail/thankyou\.xcs")]
    [MediaTypes("text/html")]
    class SendMailThankyou : StaticResource
    {
        public SendMailThankyou()
        {
            this.Content = Helper.ReadFile("/xcs/content/sendmail/thankyou.html");
        }
    }
}

the redirect to the StaticResource class is an added flourish, but handy. i'm not sure if this will be part of the final release or if i'll roll something else into the base class (like a pointer to a document, etc.).

anyway, i've been wanting to implement an SMTP-based resource for quite some time and i finally sat down and pulled one together. nice to have!

code