#!/bin/bash echo "Content-type: text/html" echo "" # Log the raw POST data for debugging read POST_DATA echo "POST Data: $POST_DATA" >> /tmp/contact_form.log # URL decoding function urldecode() { local url_encoded="${1//+/ }" printf '%b' "${url_encoded//%/\\x}" } # Parse the form data using IFS NAME="" EMAIL="" SUBJECT="" MESSAGE="" IFS='&' # Split fields by "&" for param in $POST_DATA; do IFS='=' read -r key value <<< "$param" key=$(urldecode "$key") value=$(urldecode "$value") case $key in name) NAME="$value" ;; email) EMAIL="$value" ;; subject) SUBJECT="$value" ;; message) MESSAGE="$value" ;; esac done # Log the parsed values for debugging echo "Name: $NAME, Email: $EMAIL, Subject: $SUBJECT, Message: $MESSAGE" >> /tmp/contact_form.log # Create the email with proper headers EMAIL_BODY=$(cat <> /tmp/contact_form.log # Send the email using msmtp echo "$EMAIL_BODY" | msmtp info@willowmecreations.com, bethany@willowmecreations.com # Response back to the browser cat <

Message Sent Successfully!

Thank you for reaching out. You will be redirected to the homepage shortly.

If not, click here to return to the homepage.

EOF