A secure PHP contact form to allow strangers to send messages and attachments safely.
- Validated HTML form with branding and CSS
- Supports file upload (max 20MB)
- CAPTCHA using free/libre image generation
- Secure email via PHPMailer (SMTP with TLS)
- Fallback: saves uploaded files to disk if mail fails
- Clone this repo and
cd
into the directory. - Run
composer install
. - Configure SMTP settings in
submit.php
. - Ensure
../uploads/
exists and is writable by the web server.
mkdir -p ../uploads
chmod 750 ../uploads
chown www-data:www-data ../uploads
- Install fonts if needed for CAPTCHA:
arial.ttf
orLiberationSans-Regular.ttf
should be in the script directory.
- Session-based
- Expires immediately on use
- Reloads on page refresh
- Files are not scanned for malware – consider adding antivirus.
- SMTP passwords should be moved to environment variables or config files outside webroot.
- PHP errors are not shown to users – check logs (
error_log
).
- Use
composer update
to update dependencies. - Enable GitHub Dependabot or similar for alerts on new versions.
MIT (or your preferred license).