packagist craftcms/contact-form 4.0.0

one hour ago

Contact Form has been completely rebuilt for Craft 6.x! We are using this release to show off some cool new Laravel features, like validation, routing, events, and mailers.

  • Contact Form now requires Craft CMS 6.0 or later and PHP 8.5 or later, and runs natively on Craft 6 without the craftcms/yii2-adapter package. See UPGRADE.md.
  • Plugin settings can now be overridden from config/craft/contact-form.php. Run php artisan vendor:publish --tag=contact-form to create it.
  • Added the rateLimit setting, which limits how many submissions each IP address can make per minute. Rate-limited submissions get an error flash (or a 429 response for Ajax requests).
  • Notifications are now sent to all of the configured recipients at once, rather than as one message per recipient.
  • You now have full control over the contents of email notifications, via Utilities → System Messages.
  • Additional fields (like message[referralSource]) can now be validated with rules defined in config/craft/contact-form.php.
  • allowedMessageFields now rejects unlisted message sub-fields with a validation error, for both lists of names and maps of rules. message[body] is always allowed.
  • Fields can now be nested (i.e. message[referral][primary][name]) and are output recursively in notifications.
  • Suppressed notifications and failures with the mail driver have been consolidated into a single error state. Spam submissions still appear to succeed, and are logged instead of sent.

Deprecated

  • The prependSubject setting is no longer necessary, as the notification subject can be customized (and localized!) via the System Messages utility.

Removed

All classes in the craft\contactform\* namespace have been removed. Here are the most relevant changes:

  • craft\contactform\models\Submission was removed in favor of a ruleset that validates the plain request data.
  • The craft\contactform\Mailer class has been eliminated, in favor of building the message directly in the controller. The sender’s name is compiled by CraftCms\ContactForm\Submission\Sender, and the notification body/summary is compiled by CraftCms\ContactForm\Submission\Summary.
  • craft\contactform\Mailer::EVENT_BEFORE_SEND (and craft\contactform\events\SendEvent) must be replaced with a listener for CraftCms\ContactForm\Events\MessageSending.
    • Set $event->isSpam = true or $event->isValid = false to prevent sending.
    • You can access all of the previous data via the single CraftCms\Cms\SystemMessage\Mailables\SystemMessageMailable $message event property (i.e. $message->to or $message->variables).
  • craft\contactform\Mailer::EVENT_AFTER_SEND (and craft\contactform\events\SendEvent) must be replaced with a listener for CraftCms\ContactForm\Events\MessageSent.
  • Validation rules should be added via configuration (in config/craft/contact-form.php), or in a listener (for the CraftCms\Cms\Validation\Events\ValidationRulesResolving event).

Don't miss a new contact-form release

NewReleases is sending notifications on new releases.