paulbunyannet / form_mail
Form to email helper
Installs: 10 007
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 4
Forks: 1
Open Issues: 0
Requires
- php: >=7.4
- brandonwamboldt/utilphp: 1.1.*
- doctrine/dbal: ^3.1
- fideloper/proxy: ^4.4
- guzzlehttp/guzzle: ^7.0.1
- laravel/framework: ^8.0
- laravel/helpers: ^1.1
- mustache/mustache: ^2.11
- paulbunyannet/bandolier: ^1.8
- paulbunyannet/form_mail_template: 1.04.x
- paulbunyannet/premailer: ^2.0
Requires (Dev)
- codeception/c3: ^2.4
- codeception/codeception: ^4.1
- codeception/module-asserts: ^1.0.0
- codeception/module-laravel5: ^1.1
- mockery/mockery: ^1.4
- phpunit/phpunit: ^9.0
This package is auto-updated.
Last update: 2021-09-20 16:26:00 UTC
README
Form Mail
A laravel package to capture submitted for fields and send out response to a recipient.
Setup
- Add providers to your config/app.php file:
Pbc\FormMail\Providers\FormMailServiceProvider::class,
Pbc\FormMailTemplate\Providers\FormMailTemplateServiceProvider::class,
- Run
php artisan vendor:publish
to get the config and database migration for this package. - Run
php artisan migrate
to install the package table
Config
branding
string used for branding the email messagerules
extra form validation fieldsqueue
whether to queue this message or send out right awayconfirmation
whether to send a confirmation message
Conventions
Recipient
This package will use the current route for generating the email recipient of the message. For example, if there is a route is "contact-us" and the current site's APP_URL
is "http://www.example.com" then the recipient will be "contact-us@example.com".
Fields
By default the package requires three fields (in addition to CSRF):
name
, requiredemail
, required and valid emailfields
, required and must be an array. The fields list is used for labeling fields in the responces. The array should be formatted['field_name'=>'Field Label']
. If no lable is found for a particular field, the field name will be used.
Any other required fields can be added to the config/form_mail.php
config file.
As with language, you can add rules that are specific to a path by using the route name as the ley were the rules are located.
Branding
Add a graphic/html/whatever to the branding config item and it will be injected at the top of the email message. If branding is missing the branding will default to a language string ':domain :form Form'
.
Messages
To add a verbage (success message, what to do next, etc.) to the top of the message add a line to the resources/lang/vendor/pbc_form_mail/en/body.php
using the route name and the the following keys:
recipient
used for email going to recipientsender
used in both the return value fromPbc\FormMail\Http\Controllers\FormMailController@requestHandler
and the confirmation message if option is turned on.
For example, if you had a route to App\Http\Controllers\FormController@send
you would format your message array like:
'form' => [
'send' => [
'sender' => 'Thanks for filling out the :form form, we will get back to you as soon as possible! This is a summary of the form you submitted. A copy of this form will be forwarded to :recipient.',
'recipient' => 'A new response from the :form was submitted at :time from :domain.',
'subject' => [
'sender' => 'Your form message has been received!',
'recipient' => 'A new form submission created on :url',
]
]
Custom Subject Line
There is a helper that will auto create a subject for the message. If you want a custom one add a array key subject
with keys sender
and recipient
like the above example.