A guestbook with Perl, CGI and email. whooo

This commit is contained in:
Yorhel 2022-03-28 16:08:30 +02:00
parent edb6edb5b6
commit 5e5225a172
8 changed files with 68 additions and 5 deletions

32
pub/cgi-bin/guestbook.cgi Executable file
View file

@ -0,0 +1,32 @@
#!/usr/bin/perl
use v5.26;
use CGI::Minimal;
die if !$ENV{CONTENT_LENGTH};
CGI::Minimal::max_read_size(128*1024);
my $cgi = CGI::Minimal->new;
die if $cgi->truncated;
open my $S, '|-', qw'/usr/sbin/sendmail -t -f dev@yorhel.nl' or die $!;
printf $S <<'_', $cgi->param('name'), $cgi->param('message');
To: dev@yorhel.nl
From: dev@yorhel.nl
Subject: Guestbook post
Content-Type: text/plain; charset='UTF-8'
Name: %s
Message:
%s
_
close $S or die;
print <<'_';
Status: 303
Content-Type: text/plain
Location: https://dev.yorhel.nl/guestbook/thanks
Redirecting...
_

View file

@ -54,7 +54,7 @@ main h3 { font-size: 120%; color: #000; margin: 1em 0 .3em 0; text-decoration: n
main code { font-family: monospace }
main pre { font-family: monospace; font-size: 80%; margin: 0 0 10px 18px; display: block; padding: 0 0 0 15px; border-left: 1px dotted #999; overflow-x: auto }
main pre * { font-size: inherit; font-family: inherit }
main p, main figure, main ul, main ol, main dl, main pre, main figure, main table { margin-bottom: 0.7em; margin-left: 1em }
main p, main figure, main ul, main ol, main dl, main pre, main figure, main table, main form { margin-bottom: 0.7em; margin-left: 1em }
main ul ul { margin-bottom: 0.5em }
main ul, main ol { margin-left: 2.5em }
main li { margin-bottom: .1em }
@ -66,6 +66,8 @@ main figcaption { display: none }
main table th, main table td { font-size: 12.8px; padding: 1px 7px }
main td em { font-style: normal; text-decoration: underline }
main table th { font-weight: bold }
main textarea { width: 95% }
main input[type="submit"] { padding: 1px 5px }
main section.footnotes hr { display: none }
main section.footnotes { margin: 40px 10px 10px 10px }