$ show craftcms/contact-form
This is a Craft CMS plugin that provides contact form functionality for websites. It allows users to create and submit contact forms with fields for name, email, subject, and message, with support for file attachments. The plugin processes form submissions, validates input, constructs email messages (both plain text and HTML), and sends them via Craft's mailer system. It follows a standard MVC architecture where controllers handle HTTP requests, models represent data (submission and settings), and services (Mailer) handle the core email processing logic. The plugin is extensible through events (beforeSend, afterSend) that allow other plugins to modify behavior. Key features include AJAX form submission support, configurable email templates, attachment handling with file type validation, and multi-language support.
The LLM identified 1 files worth highlighting for reuse:
The Mailer class handles the core logic for preparing and sending emails from contact form submissions. It demonstrates excellent separation of concerns by breaking down email composition into focused methods (getFromEmail, compileFromName, compileSubject, compileTextBody, compileHtmlBody). It properly handles multipart/alternative emails (both text and HTML versions), processes attachments with validation against allowed file types, and implements an event-driven architecture that allows other plugins to intervene before and after sending. The class shows strong craftsmanship through its clear structure, proper error handling and logging, and minimal dependencies on Craft-specific services that could be relatively easily decoupled for reuse in other contexts.