- Type: Class
- Language: PHP
- Framework: None
As I tackled more and more UCF sites during my tenure, I discovered that each individual “webmaster” had developed their own server-side implementation for sending emails of basic web form data. Rather than continue to work around their own code, I developed a PHP implementation that generically wrapped httpPost data into a simple email.
The first implementation of FormProcessor was a simple PHP class that had public properties (e.g., to, cc, and subject), some private methods to check for dangerous code (like email header injection), and a public method to send the email. Over time, the public methods have become private in favor of mutator methods, new helper methods have been added (including file attachments, filestream attachments, a development mode, etc.), and any specific stored information has been migrated to a config.ini file.
Highlights of Implementation
As complicated as it was to implement an email attachment method without a standard library, it is exceedingly satisfying to use that method in seconds now. Also, finally working with PHP in an object-oriented manner is a breath of fresh air.
At this point, I kind of wish I’d known about the PEAR Mail package, but I’m fairly proud of the implementation; it’s made it effortless for our web content updaters and designers to implement fairly powerful email operations without needing to know much (if anything) about PHP. It continues to make PHP development and deployment speedy and predictable, and it has been integrated into the Template Engine I built to standardize our layouts.