Skip to content
Newer
Older
100755 49 lines (35 sloc) 1.17 KB
fbcfdf3 @xsawyerx starting to play with email handling
xsawyerx authored Aug 31, 2009
1 #!/usr/bin/perl
2
3 use strict;
4 use warnings;
5
6 use CGI; # or CGI::Simple ?
38c7cff adding JSON::XS
sawyer authored Sep 4, 2009
7 use JSON::XS;
fbcfdf3 @xsawyerx starting to play with email handling
xsawyerx authored Aug 31, 2009
8 use Email::Stuff;
9
10 sub error {
12afa72 fixing error and not requiring submit param - still doesn't work
sawyer authored Sep 19, 2009
11 my $error_msg = shift;
fbcfdf3 @xsawyerx starting to play with email handling
xsawyerx authored Aug 31, 2009
12
c396d13 disabling unnecessary variables
sawyer authored Sep 19, 2009
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 Aug 31, 2009
16
12afa72 fixing error and not requiring submit param - still doesn't work
sawyer authored Sep 19, 2009
17 print encode_json { error => $error_msg };
18
19 exit 0;
fbcfdf3 @xsawyerx starting to play with email handling
xsawyerx authored Aug 31, 2009
20 }
21
22 my $cgi = CGI->new();
23
12afa72 fixing error and not requiring submit param - still doesn't work
sawyer authored Sep 19, 2009
24 print $cgi->header( -charset => 'UTF-8' );
fbcfdf3 @xsawyerx starting to play with email handling
xsawyerx authored Aug 31, 2009
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 Sep 19, 2009
35 error('Missing name or text');
fbcfdf3 @xsawyerx starting to play with email handling
xsawyerx authored Aug 31, 2009
36 }
37
3eaa0ac adding comment to mail script
sawyer authored Sep 20, 2009
38 # this should work but it didn't for me
39 # maybe it was my sendmail definitions
40 # but i didn't have the time to debug it
fbcfdf3 @xsawyerx starting to play with email handling
xsawyerx authored Aug 31, 2009
41 Email::Stuff->from($from)
42 ->to($recipient)
43 ->text_body($text)
44 ->subject($subject)
45 ->send;
46
12afa72 fixing error and not requiring submit param - still doesn't work
sawyer authored Sep 19, 2009
47 print encode_json { success => 'imminent' };
48
Something went wrong with that request. Please try again.