Skip to content
Newer
Older
100755 46 lines (32 sloc) 1.05 KB
fbcfdf3 @xsawyerx starting to play with email handling
xsawyerx authored
1 #!/usr/bin/perl
2
3 use strict;
4 use warnings;
5
6 use CGI; # or CGI::Simple ?
38c7cff adding JSON::XS
sawyer authored
7 use JSON::XS;
fbcfdf3 @xsawyerx starting to play with email handling
xsawyerx authored
8 use Email::Stuff;
9
10 sub error {
12afa72 fixing error and not requiring submit param - still doesn't work
sawyer authored
11 my $error_msg = shift;
fbcfdf3 @xsawyerx starting to play with email handling
xsawyerx authored
12
c396d13 disabling unnecessary variables
sawyer authored
13 # we don't really need those since we're updating the page with Jemplate
14 #my $return_link_url = $cgi->param('return_link_url') || q{};
15 #my $return_link_title = $cgi->param('return_link_title') || q{};
fbcfdf3 @xsawyerx starting to play with email handling
xsawyerx authored
16
12afa72 fixing error and not requiring submit param - still doesn't work
sawyer authored
17 print encode_json { error => $error_msg };
18
19 exit 0;
fbcfdf3 @xsawyerx starting to play with email handling
xsawyerx authored
20 }
21
22 my $cgi = CGI->new();
23
12afa72 fixing error and not requiring submit param - still doesn't work
sawyer authored
24 print $cgi->header( -charset => 'UTF-8' );
fbcfdf3 @xsawyerx starting to play with email handling
xsawyerx authored
25
26 my $subject = $cgi->param('subject') || q{};
27 my $name = $cgi->param('realname') || q{};
28 my $email = $cgi->param('email') || q{};
29 my $text = $cgi->param('text') || q{};
30 my $recipient = q{andy@petdance.com}; # this shouldn't be in the form
31 my $from = qq{$name <$email>};
32
33 if ( !$name || !$text ) {
34 # a name and text are essential
12afa72 fixing error and not requiring submit param - still doesn't work
sawyer authored
35 error('Missing name or text');
fbcfdf3 @xsawyerx starting to play with email handling
xsawyerx authored
36 }
37
38 Email::Stuff->from($from)
39 ->to($recipient)
40 ->text_body($text)
41 ->subject($subject)
42 ->send;
43
12afa72 fixing error and not requiring submit param - still doesn't work
sawyer authored
44 print encode_json { success => 'imminent' };
45
Something went wrong with that request. Please try again.