I put together this script for my friend huphtur and figured it was worth posting so other people could use it. It’s very customizable but requires you to configure all of the fields you’ll be using and create a template for the email message. Here’s the quick readme.txt I put together:
mail-handler
This is a simple formmail tool that is fairly customizable and works with attachments. Instructions:
Create a form and point it at mail-handler.php.
Edit mail-handler.php to call out field names and types (string, text, email, file), specify which fields are required, and configure the message. $formvars should call out all fields being sent from the form, and their types. $required should contain an array of fields required before the message will be sent. $email contains the actual email configuration, including template filename, To:, From:, Cc:, Bcc:, which files to attach, and where to direct the browser on success or failure.
Create a message template. mail-handler.php will automatically replace text such as %name% with a form variable called ‘name’ if it is specified in the configuration. It also includes %remote_ip% and %date% by default.
Cross your fingers and try it out.
View on Github: php-simple-mail-handler on Github
Download: simple-php-mail-handler latest ZIP
test.php (in the .tar.gz) is the sample form.