Permalink
Browse files

starting to play with email handling

Signed-off-by: Andy Lester <andy@petdance.com>
  • Loading branch information...
1 parent 1b05706 commit fbcfdf3ec708fcd9a91b2f0c88cfcb1d6f33875d @xsawyerx xsawyerx committed with Aug 31, 2009
Showing with 42 additions and 0 deletions.
  1. +42 −0 formmail.pl
View
42 formmail.pl
@@ -0,0 +1,42 @@
+#!/usr/bin/perl
+
+# TODO:
+# - use Jemplate
+
+use strict;
+use warnings;
+
+use CGI; # or CGI::Simple ?
+use Email::Stuff;
+
+sub error {
+ my $cgi = shift;
+
+ my $return_link_url = $cgi->param('return_link_url') || q{};
+ my $return_link_title = $cgi->param('return_link_title') || q{};
+
+}
+
+my $cgi = CGI->new();
+
+# make sure the form was submitted
+$cgi->param('submit') || error($cgi);
+
+my $subject = $cgi->param('subject') || q{};
+my $name = $cgi->param('realname') || q{};
+my $email = $cgi->param('email') || q{};
+my $text = $cgi->param('text') || q{};
+my $recipient = q{andy@petdance.com}; # this shouldn't be in the form
+my $from = qq{$name <$email>};
+
+if ( !$name || !$text ) {
+ # a name and text are essential
+ error($cgi);
+}
+
+Email::Stuff->from($from)
+ ->to($recipient)
+ ->text_body($text)
+ ->subject($subject)
+ ->send;
+

0 comments on commit fbcfdf3

Please sign in to comment.