Getting started

Now let's start building our app. Not being very original, I decided to
go with a Christmas theme: the app will allow people to let their would-be
Santa know what they want for Christmas. So we'll need the user's email and
name, Santa's email and a description for the gift. Wrap all this in an
email and deliver to Santa :)

Obviously I'll just focus on the email part, so I'll leave important stuff
like input validation or DOS protection (you don't want some kiddie sending
gazillions of emails through your app) as an exercise to the reader.

After the POST is handled, we redirect back, but it would be useful to
show some feedback. Add this in index.tt:

[% IF c.req.param('success') %] <p>Your wish is on its way to Santa!</p> [% END %]

Using an email template

So now you know how to quickly send emails from Catalyst. But stuffing
that message body in a string is rather dirty. This is where
Catalyst::View::Email::Template comes handy. It will use your default
view to render a template, assemble a multi-part email using
Email::MIME::Creator and send it out.

Now you can change your email templates without touching the controller code. Neat!

What now?

You probably want more features, like sending HTML email or attaching files.
Catalyst::View::Email handles these things well: instead of directly setting
the email body, you can pass an arrayref with Email::Mime parts , and there's
a nice example in the documentation.

So go read the docs and learn about the other features, and you can always bug us
on IRC ( irc.perl.org , #catalyst) if things don't work out.