2017 © Pedro Peláez
 

library contactform

A basic contact form of email address, message and Google ReCaptcha validation

image

kevinorriss/contactform

A basic contact form of email address, message and Google ReCaptcha validation

  • Sunday, February 12, 2017
  • by kevinorriss
  • Repository
  • 2 Watchers
  • 1 Stars
  • 160 Installations
  • HTML
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 5 Versions
  • 7 % Grown

The README.md

ContactForm

A simple contact form where a user enters their email address, message and passes a Google reCAPTCHA robot test. The message is then sent to the configured email address., (*1)

How it works

This library adds contact form functionality to your Laravel application. Two new routes (get and post) are set up under the "contact" url. A view needs to be set up, but this library provides a partial containing the form HTML, or you may create your own view with application specific layout and CSS styles., (*2)

Installation

  1. Add ContactForm to your composer.json file under require:, (*3)

    "kevinorriss\contactform": "1.1.*", (*4)

  2. Add the ContactFormServiceProvider to your app.php file:, (*5)

    KevinOrriss\ContactForm\ContactFormServiceProvider::class,, (*6)

  3. Run composer update, (*7)

Usage

Google reCAPTCHA

This library makes use of Google's reCAPTCHA to help stop the contact form being spammed. In order to use this follow these steps:, (*8)

  1. Follow the Usage section from Google's reCAPTCHA READMME file, to generate a site key and secret for your application., (*9)

  2. Add your reCAPTCHA secret and key to your application environment file, for example:, (*10)

    RECAPTCHA_SECRET=my_recaptcha_secret
    RECAPTCHA_SITE_KEY=my_recaptcha_site_key
    

Email configuration

You must first set up your mail driver, please refer to the Laravel documentation for this., (*11)

  1. Add the following to your application's environment file, (*12)

    CONTACT_FORM_EMAIL=example@myapplication.com
    CONTACT_FORM_NAME="Example Name"
    

This is the email address that the users message will be sent to., (*13)

  1. Add these optional settings to your environment file, (*14)

    CONTACT_FORM_SUBJECT="<YOUR SUBJECT>"
    CONTACT_FORM_SUCCESS="<YOUR SUCCESS MESSAGE>"
    

These allow you to override the subject of the email and also the flash message that the users sees when the email is sent successfully., (*15)

Example

A simple view

To get going, create a file named contact.blade.php in the resources/views folder and add the following:, (*16)

<!DOCTYPE html>
<html>
    <head>
        <title>Contact Form</title>
        @include('contactform::stylesheet')
    </head>
    <body>
        <div class="container">
            <div class="content">
                @include('contactform::form', ['heading' => 'Contact Me'])
            </div>
        </div>
        @include('contactform::javascript')
    </body>
</html>

This form uses Bootstrap for style which is included in the contactform::stylesheet partial., (*17)

When including the form itself, you can provide an optional array with a heading key which overrides the panel heading (defaults to "Contact Form")., (*18)

By default, the contact form controller will look for contact.blade.php, you can override this by creating an entry in your application's environment file such as:, (*19)

CONTACT_FORM_VIEW="mycontactformview", (*20)

You will then need to name your view file to match this., (*21)

Javascript

The contactform::javascript partial includes three extra partials, one each for:, (*22)

  1. jQuery (contactform::jquery)
  2. Bootstrap (contactform::bootstrap)
  3. reCAPTCHA (contactform::recaptcha)

If your template already includes jQuery or bootstrap, or you simply do not want to use bootstrap then you can replace the contactform::javascript partial and use only the ones you need., (*23)

Authors

See also the list of contributors who participated in this project., (*24)

License

This project is licensed under the MIT License - see the LICENSE file for details, (*25)

The Versions

12/02 2017

dev-master

9999999-dev https://github.com/kevinorriss/contactform

A basic contact form of email address, message and Google ReCaptcha validation

  Sources   Download

MIT

The Requires

 

form contact

12/02 2017

1.1.1

1.1.1.0 https://github.com/kevinorriss/contactform

A basic contact form of email address, message and Google ReCaptcha validation

  Sources   Download

MIT

The Requires

 

form contact

12/02 2017

1.1.0

1.1.0.0 https://github.com/kevinorriss/contactform

A basic contact form of email address, message and Google ReCaptcha validation

  Sources   Download

MIT

The Requires

 

form contact

06/07 2016

dev-contactform

dev-contactform https://github.com/kevinorriss/contactform

A basic contact form of email address, message and Google ReCaptcha validation

  Sources   Download

MIT

The Requires

 

form contact

06/07 2016

1.0.0

1.0.0.0 https://github.com/kevinorriss/contactform

A basic contact form of email address, message and Google ReCaptcha validation

  Sources   Download

MIT

The Requires

 

form contact