commit 5efead129e88c9bbe1c9e0a30881c8afa010a556 Author: Jack-Benny Persson Date: Thu Jan 19 16:43:43 2023 +0100 Initial commit diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..09d3020 --- /dev/null +++ b/LICENSE @@ -0,0 +1,15 @@ +Copyright (C) 2023 Jack-Benny Persson + +This program is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2 of the License, or +(at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA diff --git a/README.md b/README.md new file mode 100644 index 0000000..617eeff --- /dev/null +++ b/README.md @@ -0,0 +1,18 @@ +# Encrypted form +This is a small project to send encrypted form data to a recipient. +The data is encrypted using the form recipient's PGP key. + +## Requirements +Apache/NGINX with PHP and the GnuGP PHP module. The module is installed with +`apt install php-gnupg` on Debian and Ubuntu systems. + +The Apache/NGINX process also needs write permission to the GnuPG home +directory (set the GnuPG home directory in `contact.php`). + +You also need to set the following variables in `contact.php`: + +* `$recipient` (email of the form recipient) +* `$subject` (a subject line for the email) +* `$key` (the **public** PGP key of the recipient) +* `$fingerprint` (the fingerprint of the public PGP key) + diff --git a/contact.html b/contact.html new file mode 100644 index 0000000..fca9df6 --- /dev/null +++ b/contact.html @@ -0,0 +1,26 @@ + + + + + + + Contact form + + + +
+
+ Contact us + + + + +
+
+ + +
+ + + diff --git a/contact.php b/contact.php new file mode 100644 index 0000000..3917ff1 --- /dev/null +++ b/contact.php @@ -0,0 +1,84 @@ +import($key); + +// Add the key +$gpg->addencryptkey($fingerprint); + +// Encryt the message +$encrypted_message = $gpg->encrypt("Name: $name\nE-mail: $email\n\nMessage: $message"); + +$headers = 'From: "Contact form" ' . "\r\n" . + 'Reply-To: info@example.com' . "\r\n" . + 'Content-Type: text/plain; charset=UTF-8' . "\r\n" . + 'X-Mailer: PHP/' . phpversion(); + + +// Send the mail (this requires a fully working SMTP-server on the host) +mail($recipient, $subject, $encrypted_message, $headers); + +?> + + + + + + + + Your message has been sent + + +

Your message has been sent

+

+ Thank you for your message
+ Best regards, NNN +

+ + +