Changeset 152
- Timestamp:
- Oct 24, 2006, 6:22:51 PM (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/npemap.org.uk/cgi/problem.fcgi
r135 r152 8 8 9 9 use DBI; 10 use MIME::Lite; 11 use Email::Valid; 10 12 use CGI::Fast qw/:standard -debug/; 11 13 … … 47 49 next REQUEST; 48 50 } 49 my $type = $cgi->param('type'); 50 my $email = $cgi->param('email'); 51 my $comment= $cgi->param('comment'); 51 52 if (defined $cgi->param('email') and !(Email::Valid->address($cgi->param('email')))) { 53 print_err ("Invalid email address supplied"); 54 next REQUEST; 55 } 56 57 my $type = $cgi->param('type') || 'none'; 58 my $from = $cgi->param('email') || 'webmaster@npemap.org.uk'; 59 my $comment = $cgi->param('comment'); 52 60 my $subject = "[$type] comment from npemap.org.uk "; 53 my $message = <<"END";54 61 55 From $email 62 my $msg = MIME::Lite->new( 63 From => $from, 64 To => 'webmaster@npemap.org.uk', 65 Subject => $subject, 66 Data => $comment); 67 $msg->send; 56 68 57 $comment58 59 END60 sendEmail('webmaster@npemap.org.uk', 'webmaster@npemap.org.uk', $subject, $message) ;61 69 print "Content-type: text/html\n\n"; 62 70 print "<html><head><title>Thanks</title></head>"; … … 87 95 return $dbh = DBI->connect_cached($data_source, $dbuser, $dbpass); 88 96 } 89 90 # Simple Email Function91 # ($to, $from, $subject, $message)92 sub sendEmail93 {94 my ($to, $from, $subject, $message) = @_;95 my $sendmail = '/usr/lib/sendmail';96 open(MAIL, "|$sendmail -oi -t");97 print MAIL "From: $from\n";98 print MAIL "To: $to\n";99 print MAIL "Subject: $subject\n\n";100 print MAIL "$message\n";101 close(MAIL);102 }
Note: See TracChangeset
for help on using the changeset viewer.