GithubHelp home page GithubHelp logo

craftcms / contact-form Goto Github PK

View Code? Open in Web Editor NEW
293.0 20.0 93.0 533 KB

Add a simple contact form to your Craft CMS site.

Home Page: https://plugins.craftcms.com/contact-form

License: MIT License

PHP 89.87% Twig 10.13%
craftcms craft-plugin craft3 contact-form email craft2

contact-form's Introduction

Contact Form for Craft CMS

This plugin allows you to add an email contact form to your website.

Requirements

This plugin requires Craft CMS 4.0.0+ or 5.0.0+.

Installation

You can install this plugin from the Plugin Store or with Composer.

From the Plugin Store

Go to the Plugin Store in your project’s Control Panel and search for “Contact Form”. Then click on the “Install” button in its modal window.

With Composer

Open your terminal and run the following commands:

# go to the project directory
cd /path/to/my-project.test

# tell Composer to load the plugin
composer require craftcms/contact-form

# tell Craft to install the plugin
php craft plugin/install contact-form

Usage

Your contact form template can look something like this:

{% macro errorList(errors) %}
    {% if errors %}
        {{ ul(errors, {class: 'errors'}) }}
    {% endif %}
{% endmacro %}

{% set submission = submission ?? null %}

<form method="post" action="" accept-charset="UTF-8">
    {{ csrfInput() }}
    {{ actionInput('contact-form/send') }}
    {{ redirectInput('contact/thanks') }}

    <h3><label for="from-name">Your Name</label></h3>
    {{ input('text', 'fromName', submission.fromName ?? '', {
        id: 'from-name',
        autocomplete: 'name',
    }) }}
    {{ submission ? _self.errorList(submission.getErrors('fromName')) }}

    <h3><label for="from-email">Your Email</label></h3>
    {{ input('email', 'fromEmail', submission.fromEmail ?? '', {
        id: 'from-email',
        autocomplete: 'email',
    }) }}
    {{ submission ? _self.errorList(submission.getErrors('fromEmail')) }}

    <h3><label for="subject">Subject</label></h3>
    {{ input('text', 'subject', submission.subject ?? '', {
        id: 'subject',
    }) }}
    {{ submission ? _self.errorList(submission.getErrors('subject')) }}

    <h3><label for="message">Message</label></h3>
    {{ tag('textarea', {
        text: submission.message ?? '',
        id: 'message',
        name: 'message',
        rows: 10,
        cols: 40,
    }) }}
    {{ submission ? _self.errorList(submission.getErrors('message')) }}

    <button type="submit">Send</button>
</form>

The only required fields are fromEmail and message. Everything else is optional.

Redirecting after submit

If you have a redirect hidden input, the user will get redirected to it upon successfully sending the email. The following variables can be used within the URL/path you set:

  • {fromName}
  • {fromEmail}
  • {subject}

For example, if you wanted to redirect to a contact/thanks page and pass the sender’s name to it, you could set the input like this:

{{ redirectInput('contact/thanks?from={fromName}') }}

On your contact/thanks.html template, you can access that from parameter using craft.app.request.getQueryParam():

<p>Thanks for sending that in, {{ craft.app.request.getQueryParam('from') }}!</p>

Note that if you don’t include a redirect input, the current page will get reloaded.

Displaying flash messages

When a contact form is submitted, the plugin will set a notice (Craft 4) or success (Craft 5+) flash message on the user session. You can display it in your template like this:

{% if craft.app.session.hasFlash('success') %}
    <p class="message success">{{ craft.app.session.getFlash('success') }}</p>
{% elseif craft.app.session.hasFlash('error') %}
    <p class="message error">{{ craft.app.session.getFlash('error') }}</p>
{% endif %}

Adding additional fields

You can add additional fields to your form by splitting your message field into multiple fields, using an array syntax for the input names:

<h3><label for="message">Message</label></h3>
<textarea rows="10" cols="40" id="message" name="message[body]">{{ submission.message.body ?? '' }}</textarea>

<h3><label for="phone">Your phone number</label></h3>
<input id="phone" type="text" name="message[Phone]" value="">

<h3>What services are you interested in?</h3>
<label><input type="checkbox" name="message[Services][]" value="Design"> Design</label>
<label><input type="checkbox" name="message[Services][]" value="Development"> Development</label>
<label><input type="checkbox" name="message[Services][]" value="Strategy"> Strategy</label>
<label><input type="checkbox" name="message[Services][]" value="Marketing"> Marketing</label>

If you have a primary “Message” field, you should name it message[body], like in that example.

An email sent with the above form might result in the following message:

• Name: John Doe
• Email: [email protected]
• Phone: (555) 123-4567
• Services: Design, Development

Hey guys, I really loved this simple contact form (I'm so tired of agencies
asking for everything but my social security number up front), so I trust
you guys know a thing or two about usability.

I run a small coffee shop and we want to start attracting more freelancer-
types to spend their days working from our shop (and sipping fine coffee!).
A clean new website with lots of social media integration would probably
help us out quite a bit there. Can you help us with that?

Hope to hear from you soon.

Cathy Chino

By default, there’s no restriction on which keys can be included on message. You can limit which fields are allowed using the allowedMessageFields setting in config/contact-form.php:

<?php

return [
    'allowedMessageFields' => ['Phone', 'Services'],
];

Overriding plugin settings

If you create a config file in your config/ folder called contact-form.php, you can override the plugin’s settings in the Control Panel. Since that config file is fully multi-environment aware, this is a handy way to have different settings across multiple environments.

Here’s what that config file might look like along with a list of all of the possible values you can override.

<?php

return [
    'toEmail'             => '[email protected]',
    'prependSubject'      => '',
    'prependSender'       => '',
    'allowAttachments'    => false,
    'successFlashMessage' => 'Message sent!'
];

Dynamically adding email recipients

You can programmatically add email recipients from your template by adding a hidden input field named toEmail like so:

<input type="hidden" name="toEmail" value="{{ '[email protected]'|hash }}">

If you want to add multiple recipients, you can provide a comma separated list of emails like so:

<input type="hidden" name="toEmail" value="{{ '[email protected],[email protected]'|hash }}">

Then from your config/contact-form.php config file, you’ll need to add a bit of logic:

<?php

$config = [];
$request = Craft::$app->request;

if (
    !$request->getIsConsoleRequest() &&
    ($toEmail = $request->getValidatedBodyParam('toEmail')) !== null
) {
    $config['toEmail'] = $toEmail;
}

return $config;

In this example if toEmail does not exist or fails validation (it was tampered with), the plugin will fallback to the “To Email” defined in the plugin settings, so you must have that defined as well.

File attachments

If you would like your contact form to accept file attachments, follow these steps:

  1. Go to Settings → Contact Form in the Control Panel, and make sure the plugin is set to allow attachments.
  2. Make sure your opening HTML <form> tag contains enctype="multipart/form-data".
  3. Add a <input type="file" name="attachment"> to your form.
  4. If you want to allow multiple file attachments, use multiple <input type="file" name="attachment[]" multiple> inputs.

Ajax form submissions

You can optionally post contact form submissions over Ajax if you’d like. Just send a POST request to your site with all of the same data that would normally be sent:

$('#my-form').submit(function(ev) {
    // Prevent the form from actually submitting
    ev.preventDefault();

    // Send it to the server
    $.post({
        url: '/',
        dataType: 'json',
        data: $(this).serialize(),
        success: function(response) {
            $('#thanks').text(response.message).fadeIn();
        },
        error: function(jqXHR) {
          // The response body will be an object containing the following keys:
          // - `message` – A high level message for the response
          // - `submission` – An object containing data from the attempted submission
          // - `errors` – An object containing validation errors from the submission, indexed by attribute name
          alert(jqXHR.responseJSON.message);
        }
    });
});

The afterValidate event

Modules and plugins can be notified when a submission is being validated, providing their own custom validation logic, using the afterValidate event on the Submission model:

use craft\contactform\models\Submission;
use yii\base\Event;

// ...

Event::on(Submission::class, Submission::EVENT_AFTER_VALIDATE, function(Event $e) {
    /** @var Submission $submission */
    $submission = $e->sender;
    
    // Make sure that `message[Phone]` was filled in
    if (empty($submission->message['Phone'])) {
        // Add the error
        // (This will be accessible via `message.getErrors('message.phone')` in the template.)
        $submission->addError('message.phone', 'A phone number is required.');
    }
});

The beforeSend event

Modules and plugins can be notified right before a message is sent out to the recipients using the beforeSend event. This is also an opportunity to flag the message as spam, preventing it from getting sent:

use craft\contactform\events\SendEvent;
use craft\contactform\Mailer;
use yii\base\Event;

// ...

Event::on(Mailer::class, Mailer::EVENT_BEFORE_SEND, function(SendEvent $e) {
    $isSpam = // custom spam detection logic...

    if ($isSpam) {
        $e->isSpam = true;
    }
});

The afterSend event

Modules and plugins can be notified right after a message is sent out to the recipients using the afterSend event.

use craft\contactform\events\SendEvent;
use craft\contactform\Mailer;
use yii\base\Event;

// ...

Event::on(Mailer::class, Mailer::EVENT_AFTER_SEND, function(SendEvent $e) {
    // custom logic...
});

Using a “Honeypot” field

Support for the honeypot captcha technique to fight spam has been moved to a separate plugin that complements this one.

contact-form's People

Contributors

angrybrad avatar billmn avatar boboldehampsink avatar brandonkelly avatar cityzen avatar danbrellis avatar dommmel avatar fyrebase avatar hiasl avatar i-just avatar jasonetco avatar lassemt avatar machour avatar makeilalundy avatar michtio avatar narration-sd avatar nathanheffley avatar nicholashamilton avatar nstcactus avatar olivierbon avatar rafrobeat avatar realjoshharrison avatar sa3dany avatar selvinortiz avatar swey avatar timkelty avatar tpmatthes avatar ttempleton avatar watarutmnh avatar williamisted avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

contact-form's Issues

File attachement with AJAX

I'm having trouble receiving attachments when using AJAX form submission.

I'm passing the form data through with:

var data = new FormData(this);

Because serialize() won't work on file fields, but unfortunately this still isn't working (email is sent, attachment ignored).

Any ideas?

Doesnt submit or redirect? (Just help)

Hello,

I have used this plugin on three different occasions with no issues whatsoever, that is why I am so dumbstuck on why it doesnt work now.

I have used the exact same code on all sites - tested the email from craft - and for some reason, on submit nothing happens. The site reloads, all the inputs are still there. Here is my redirect:

I have tried redirecting to another page too. Im sure there is something so small and easily fixable that i am missing. If anyone can highlight my oversight (or any normally over looked areas that i should look in to), that would be great. THANKS!

Feature Request: save form submissions in database

It would be perfect if submissions are saved in the database and an overview of these submissions would be available in the admin area.

This could be a perfect backup tool for the submissions, as well open up new possibilities to manage contacts, potential clients, ...

Additional Fields Value

Is it possible to retrieve the value of an additional field? I've tried message.message[Phone] and other combinations but it doesn't return anything.

This is my full field <input class="fieldItem__textInput" type="phone" name="message[Phone][]" id="phone" placeholder="Phone" value="{% if message is defined %}{{ message.message[Phone] }}{% endif %}" />

Error on navigating from page

Hi,

I have implemented this contact form in my footer and its working as expected, until I click on any link and move from the main page:

Twig_Error_Runtime

Impossible to access an attribute ("fromName") on a string variable ("") in "_includes/footer" at line 57 (C:\wamp\www\autumndev\craft\app\vendor\twig\twig\lib\Twig\Template.php:388)

#0 C:\wamp\www\autumndev\craft\app\etc\templating\BaseTemplate.php(40): Twig_Template->getAttribute('', 'fromName', Array, 'any', false, false)
#1 C:\wamp\www\autumndev\craft\storage\runtime\compiled_templates\1d\d9\7011bc8fccb78c279d1426337974a0cf94ad1f27c90f6592f3bce33b1b1c.php(126): Craft\BaseTemplate->getAttribute('', 'fromName')
#2 C:\wamp\www\autumndev\craft\app\vendor\twig\twig\lib\Twig\Template.php(278): __TwigTemplate_1dd97011bc8fccb78c279d1426337974a0cf94ad1f27c90f6592f3bce33b1b1c->doDisplay(Array, Array)
#3 C:\wamp\www\autumndev\craft\app\vendor\twig\twig\lib\Twig\Template.php(252): Twig_Template->displayWithErrorHandling(Array, Array)
#4 C:\wamp\www\autumndev\craft\storage\runtime\compiled_templates\9c\bf\68451ca0ea3b938050b4f99d8b4f919f102ac30eb0a0f06c08f764464a24.php(74): Twig_Template->display(Array)
#5 C:\wamp\www\autumndev\craft\app\vendor\twig\twig\lib\Twig\Template.php(278): __TwigTemplate_9cbf68451ca0ea3b938050b4f99d8b4f919f102ac30eb0a0f06c08f764464a24->doDisplay(Array, Array)
#6 C:\wamp\www\autumndev\craft\app\vendor\twig\twig\lib\Twig\Template.php(252): Twig_Template->displayWithErrorHandling(Array, Array)
#7 C:\wamp\www\autumndev\craft\storage\runtime\compiled_templates\ef\e0\013b7ec852e7ba0e54f3e5b825242f295c7cdbd7a182b126c82816f35323.php(26): Twig_Template->display(Array, Array)
#8 C:\wamp\www\autumndev\craft\app\vendor\twig\twig\lib\Twig\Template.php(278): __TwigTemplate_efe0013b7ec852e7ba0e54f3e5b825242f295c7cdbd7a182b126c82816f35323->doDisplay(Array, Array)
#9 C:\wamp\www\autumndev\craft\app\vendor\twig\twig\lib\Twig\Template.php(252): Twig_Template->displayWithErrorHandling(Array, Array)
#10 C:\wamp\www\autumndev\craft\app\vendor\twig\twig\lib\Twig\Template.php(263): Twig_Template->display(Array)
#11 C:\wamp\www\autumndev\craft\app\vendor\twig\twig\lib\Twig\Environment.php(292): Twig_Template->render(Array)
#12 C:\wamp\www\autumndev\craft\app\services\TemplatesService.php(158): Twig_Environment->render('404', Array)
#13 C:\wamp\www\autumndev\craft\app\controllers\BaseController.php(75): Craft\TemplatesService->render('404', Array)
#14 C:\wamp\www\autumndev\craft\app\controllers\TemplatesController.php(156): Craft\BaseController->renderTemplate('404', Array)
#15 C:\wamp\www\autumndev\craft\app\framework\web\actions\CInlineAction.php(49): Craft\TemplatesController->actionRenderError()
#16 C:\wamp\www\autumndev\craft\app\framework\web\CController.php(308): CInlineAction->runWithParams(Array)
#17 C:\wamp\www\autumndev\craft\app\framework\web\CController.php(286): CController->runAction(Object(CInlineAction))
#18 C:\wamp\www\autumndev\craft\app\framework\web\CController.php(265): CController->runActionWithFilters(Object(CInlineAction), NULL)
#19 C:\wamp\www\autumndev\craft\app\framework\web\CWebApplication.php(282): CController->run('renderError')
#20 C:\wamp\www\autumndev\craft\app\framework\base\CErrorHandler.php(331): CWebApplication->runController('templates/rende...')
#21 C:\wamp\www\autumndev\craft\app\framework\base\CErrorHandler.php(204): CErrorHandler->render('error', Array)
#22 C:\wamp\www\autumndev\craft\app\etc\errors\ErrorHandler.php(112): CErrorHandler->handleException(Object(Craft\HttpException))
#23 C:\wamp\www\autumndev\craft\app\framework\base\CErrorHandler.php(129): Craft\ErrorHandler->handleException(Object(Craft\HttpException))
#24 C:\wamp\www\autumndev\craft\app\framework\base\CApplication.php(732): CErrorHandler->handle(Object(CExceptionEvent))
#25 [internal function]: CApplication->handleException(Object(Craft\HttpException))
#26 {main}

Line 57 is as follows:

<input id="fromName" type="text" name="fromName" value="{% if message is defined %}{{ message.fromName }}{% endif %}" placeholder="Name" class="form-control" >

I believe its because the form is declared on a tempalte that is included on every page, is there a fix for this?

name="fromEmail" wrong

Hi Brad

First of all I like your plugin really and use it in every Craft installation.

In the latest Craft version 2.6.2779 and current version of ContactForm (1.7.0) – I guess – I found a bug. I set the recipient address to the address of my customer and the form field for the {{ message.fromEmail }} is in my template like in your code example.
Well, every time when I send a new mail, the {{ message.fromEmail }} is not the e-mail address in the completed field, it's the system e-mail address. In my case the same like the recipient address.

Maybe you guys have some time to check this as well. I tested it in four installation and everywhere I get the same issue.

Cheers from Switzerland,
Selim

Allow for multiple attachments

Would be great if the form accepted multiple file attachments, with the fields named attachment[0], attachment[1], etc.

Required Message Field

Would it be possible to not have the message field required? Some forms do not require a message field because they collect data from other input fields.

Ajax POST is sending HTML of home page as reponse

I'm using the described Ajax method to handle contact form submissions and receiving as a response the full HTML markup from the homepage rather than the JS object that the Readme describes.

I'm pretty sure I'm following the example but just to be sure here is JS I have...

var sendValidForm = function( $form ) {
    var data = $form.serialize();
    // I'm getting the URL from a data attribute on the form in the template
    // which looks like this: data-post-to="{{ siteUrl }}"
    var postTo = $form.data('post-to');

    console.log('Form data');
    console.log(data);

    // Send it to the server
    $.post( postTo , data, function( response ) {
        if ( response.success ) {
            afterSubmission( $form );
        } else {
            console.log(response);
            formError( $form, 'An error occurred. Please try again.' );
        }
    });
};

I'm using version 1.7.0 of the plugin, version 2.5.2761 of Craft, and it's running on PHP 5.6.10. I can also confirm that the dashboard shows the plugin is installed and enabled.

Any help would be much appreciated, thanks!

Autofilling Honeypots

We just had an issue on a site where the hidden honeypot field was being autofilled by Chrome (version 50.0.2661.102) despite it having a practically nonsense name. In our tests it was being filled with the users country.

To fix this we simply added autocomplete="off" to our honeypot fields.

While this isn't a ContactForm bug, I figure it was worth letting everyone know!

Notify Page that Email has been sent

I would like to return users to the same page that they sent the email from, but wanted to know if there were any variable passed along with the request or anything, so I could display a message, letting the user know we received the email.

Email error: Could not instantiate mail function.

I know this is probably an issue with the correct mail software not being installed on the server, but I was wondering if there was a preferred method or fix for this error from the plugin developers.

Question about succesfull submit

Since we have a one page website I would always like to return to the same page, using an anchor to direct to the right section. I've managed to do so.
The errors are showing as expected, and the return is correct in case of error and on success.
I would like to detect if the form has successfully submitted so I can display a message to the user. How can I check for this?

Failed Submission Set Reload at div id

Is there anyway to stop the form from reloading at the top of the page and instead have the page reloaded at a particular id location (e.g.

) when errors are detected? Depending on where the form is located, a user may have no idea submission failed unless they scroll down to see errors.

Can't get additional Fields to work

I use the current version of your plugin (1.8.1) and can't get additional Fields to work. This is my code:

  {% set contactEntry = craft.entries.id(entry.id).first() %}
          <form method="post" action="" accept-charset="UTF-8" id="contact-form" class="contact-form">
              {{ getCsrfInput() }}
              <input type="hidden" name="action" value="contactForm/sendMessage">
              <input type="hidden" name="redirect" value="{{ contactEntry.url }}?sent=true&from={fromName}">

              {% set voiceName = craft.request.getParam('voiceName') %}
              {% if voiceName is not empty or (message is defined and message.voiceName is not empty) %}
              <p class="voice-name">
                <input id="voicename" type="text" disabled="disabled" value="{{ "Voice Actor: " | t}}{% if message is defined %}{{ message.VoiceActor }}{% else %}{{ voiceName }}{% endif %}" name="message[VoiceActor]" />
                {{ message is defined and message ? errorList(message.getErrors('voiceName')) }}
              </p>
              {% endif %}

              {% set voiceReference = craft.request.getParam('voiceReference') %}
              {% if voiceReference is not empty or (message is defined and message.voiceReference is not empty) %}
              <p class="voice-reference">
                <input id="voicereference" type="text" value="{{ "Voice Actor Reference: " | t}}{% if message is defined %}{{ message.Reference }}{% else %}{{ voiceReference }}{% endif %}" name="message[VoiceReference]" />
                {{ message is defined and message ? errorList(message.getErrors('voiceReference')) }}
              </p>
              {% endif %}
              <p class="contact-name">
                <input id="contact_name" type="text" placeholder="Ihr Name" value="{% if message is defined %}{{ message.fromName }}{% endif %}" name="fromName" />
                {{ message is defined and message ? errorList(message.getErrors('fromName')) }}
              </p>
              <p class="contact-email">
                <input id="contact_email" type="text" placeholder="Ihre E-Mail Adresse" value="{% if message is defined %}{{ message.fromEmail }}{% endif %}" name="fromEmail" />
                {{ message is defined and message ? errorList(message.getErrors('fromEmail')) }}
              </p>
              <p class="contact-message">
                <textarea id="contact_message" placeholder="Ihre Nachricht" name="message[body]" rows="15" cols="40">{% if message is defined %}{{ message.message }}{% endif %}</textarea>
                {{ message is defined and message ? errorList(message.getErrors('message')) }}
              </p>
              <input type="text" id="company" name="company" style="display:none">
              <p class="contact-submit">
                <button id="contact-submit" class="submit" type="submit">Absenden</button>
              </p>

          </form>

What am I missing? :(

fromEmail mandatory

Hi guys.

Is there a specific reason to make the fromEmail required? The vast majority of forms ask for an email but sometimes only a telephone number/address is needed.

fromEmail is incorrect?

I'm really confused about the fact that the fromEmail is not to be found in the mail that I am receiving. Not even as the reply address ... the reply address is the address of the admin. If I fill in "[email protected]" as "fromEmail" ... I expect to receive the form at the address which is configured within the plugin with the "fromEmail" as "from/reply" address. This seems to be some kind of bug?

Internal server error after submit

Hi, love Craft and this looks like a fine plugin and I'm sure it will work on my windows server as well but for now all I get is an internal server error after a successful form submission.
Any tips greatly appreciated!
Cheers, Menno

Reply-To does not work with Gmail

Unfortunately Gmail ignores the Reply-To email header if the From address is the same as the To address (or is configured as a "Send as..."-Account in the Gmail settings), as it is the case with the ContactForm plugin.

So if you receive an email from the plugin in gmail and click Reply, it fills in your own address in the To field of the reply, and not the address of the person submitting the form.

This could be fixed by adding a config setting "From Email" and configuring it with something like [email protected].

Stumped - test form submits / real form wont

I have the following code on a local testpage:

        <form class="form-contact validate-me" action="" accept-charset="UTF-8" enctype="multipart/form-data">
            <p class="caption">Graag alle vakjes met een <strong>asterisk (*)</strong> invullen.</p>
            <input type="hidden" name="action" value="contactForm/sendMessage">
            <input type="hidden" name="redirect" value="sollicitatie/bedankt">
             {# honeypot field #}
            <input id="kandidaat" name="kandidaat" type="text"  style="display:none;">
            <fieldset>
                <div class="field-container">
                    <label for="fromName">Naam en voornaam<abbr title="required"><strong>*</strong></abbr></label>
                    <input id="fromName" name="fromName" type="text" placeholder="" class="required" title="Vul je naam in" />
                </div>
                <div class="field-container">
                    <label for="rijksregisternummer">Rijksregisternummer<abbr title="required"><strong>*</strong></abbr></label>
                    <input id="rijksregisternummer" name="message[rijksregisternummer]" type="text" placeholder="" class="required" title="Een geldig rijksregisternummer is verplicht" value="" />
                </div>
                <div class="field-container">
                    <label for="woonplaats">Woonplaats<abbr title="required"><strong>*</strong></abbr></label>
                    <input id="woonplaats" name="message[woonplaats]" type="text" placeholder="" class="required" title="Een geldige woonplaats is verplicht" value="" />
                </div>
                <div class="field-container">
                    <label for="fromEmail">E-mail <abbr title="required"><strong>*</strong></abbr></label>
                    <input id="fromEmail" name="fromEmail"  type="fromEmail" placeholder="" class="required" title="Een geldig e-mail adres is verplicht" value="" />
                </div>
            </fieldset>

            <fieldset>
                    <label for="attachment">Upload je CV (.doc of .pdf)</label>
                    <p>Upload hier je CV in .doc of .PDF formaat.</p>
                    <div class="field-container">
                        <input id="attachment" name="attachment" type="file" />
                    </div>
                </fieldset>

            <fieldset>
                <div class="field-container">
                    <label for="message">Extra opmerkingen</label>
                    <textarea id="message" name="message[body]" rows="5" placeholder="Wil je ons nog iets laten weten? Dat kan hier."></textarea>
                </div>
            </fieldset>
            <fieldset class="form-submit">
                <input type="submit" value="Verstuur sollicitatie" class="button button--form">
            </fieldset>
        </form> 
        {# ===================== #}
        {# test form #}

            <form method="post" action="" accept-charset="UTF-8" enctype="multipart/form-data">
                <input type="hidden" name="action" value="contactForm/sendMessage">
                <input type="hidden" name="redirect" value="sollicitatie/bedankt">

                <input id="kandidaat" name="kandidaat" type="text">

                <h3><label for="fromName">Your Name</label></h3>
                <input id="fromName" type="text" name="fromName" value="">


                <h3><label for="fromEmail">Your Email</label></h3>
                <input id="fromEmail" type="text" name="fromEmail" value="">


                <h3><label for="subject">Subject</label></h3>
                <input id="subject" type="text" name="subject" value="">

                <h3><label for="message">Message</label></h3>
                <textarea rows="10" cols="40" id="message" name="message[body]"></textarea>

                <h3><label for="woonplaats">woonplaats</label></h3>
                <input id="woonplaats" type="text" name="message[woonplaats]" value="">

                <h3><label for="rijksregisternummer">rijksregisternummer</label></h3>
                <input id="rijksregisternummer" type="text" name="message[rijksregisternummer]" value="">

                <label for="attachment">cv upload</label>
                <input type="file" name="attachment">

                <input type="submit" value="Send">
            </form> 
            {# ===================================== #}

The test from submits fine, the actual form (which to my eyes is identical) gives a

Bad Request
The request could not be understood by the server due to malformed syntax.

error.
The query string submitted is
http://wgcdesleep.dev:8888/jobs/solliciteer?action=contactForm%2FsendMessage&redirect=sollicitatie%2Fbedankt&kandidaat=&fromName=Erwin+Heiser&message[rijksregisternummer]=6546546565&message[woonplaats]=errrrr&fromEmail=erwin.heiser%40gmail.com&attachment=bereikbaarheid_winkelhaak_2014.pdf&message[body]=eeee+e+eee+ee+

Any ideas? I'm stumped.

To Email Limitation

I have an email address set up at a domain with a hyphen. When I use that email as the "To Email" in the plugin settings, I don't receive the mail. The address works otherwise. Other addresses work as the "To Email" also.
Could it be causing a problem because of the hyphen? ex. [email protected]

All emails going to gmail spam folder

Hi guys,

Great plugin. My issue is that all my emails are going to gmails spam folder. I have had to create a hardcoded subject and create a filter in gmail to stop it going to spam.

Have you guys experienced this before? Gmails spam message is 'Why is this message in Spam? It's similar to messages that were detected by our spam filters'. Is there a setup for fromEmail and subject etc that you know of that stops it going to spam? My sender name is the same as domain name so I know it's not that issue.

Thanks!

Internal Server Error on forms with attachments

I've had several people email me saying that when submitting a form containing a file upload field (for an image) they receive the following error:

Internal Server Error: Could not access file.    

It's not happening every time, and isn't limited to a specific browser.

I tried to replicate it using large files but wasn't able to get the error myself.

Show fromEmail and fromName in message body

Is it possible to add in an option to show the sender's email address and name in the message body?

Quite often when these emails are received they are forwarded on to the relevant recipient and therefore losing the reply to address (fromName), it would be very useful if the sender's details are included in the message body as it already does for other fields in the form.

Line break in emails

When receiving the emails the info in the emails are in one line. Is there a way to add line breaks ?

Issue installing plugin

When I try and install v1.7.0 in Craft Client 2.5.276, I get the following error:

CException

Craft\Model and its behaviors do not have a method or closure named "subject".

Doesn't mean much to me. Any idea why I can't install the plugin? Thanks.

Unable to resolve the request "contactform/sendMessage"

I'm getting this error when trying to submit a form that is included at the bottom of all pages.

I have

<input type="hidden" name="action" value="contactform/sendMessage">
<input type="hidden" name="redirect" value="message-received">

which I've taken from the docs. I'm running the latest Craft build and v1.4 of the plugin.

Is there anything else I'm missing?

Required inputs

I can't find anything in the documentation... and I might be missing something obvious. But is there a way to enforce required fields?

Do I need to create my own plug-in to do so?

Required Fields

Hi, just wondering if there would be any future updates that add required fields? Essentially giving the client the ability to choose which input fields are required, including an error if the user does not enter information. Thanks in advance!

Vague error message

This is probably the same thing others are running into, but I can't seem to solve it.

I've set up a simple form, and no errors come back on form submission. However, the redirect doesn't happen, and the page comes back with all the information in the form fields. When I finally went to the plug-in page, a banner appeared and said:

There was a problem with your submission, please check the form and try again!

I've tried the test email, and it works with my real email.
I've tried creating a fake email with the same domain as the dev environment, to no avail.

What am I missing?

Post to form from different domain?

Is it / should it be possible to post the form from a different domain? I already have my accept headers to allow from * (and this works as I load json from craft on to my app)

I'm trying to post using an app, passing the required parameters, but all I get back is "the request timed out" - submitting the form from a craft template works.

I was also considering posting to my own php template on the CMS side and posting the data from there, but I'm not allowed to have php templates?

SPAM Problems + Integrate Google reCAPTCHA with ContactForm

I'm receiving about 2 SPAM messages a day, even though I've enabled the honeypot field. I'm not sure if I've implemented the feature wrong or not. When I try simulating it in my browser by filling in the field, everything works.

The form is here under Get In Touch Today at the bottom, by the way: http://www.ideabasekent.com

Has anyone had success integrating this with Google's reCAPTCHA service? I find Google's documentation and instructions to be really confusing.

onBeforeSend()

Hey Guys,
Would you be open to adding an onBeforeSend() event so that a plugin like spamguard can validate (inspect for spam) the content to be sent?

This would allow people to use your contactform without any changes and use spamguard alongside if they choose to do so with no workarounds!

Displaying form data on thanks page

I love this quick and simple plugin! However, I was wondering how you could display the information the was submitted from the form on the contact/thanks page? I'm sure its possible, just not sure how to go about accessing the information.

Should the From email address be same as Reply-to email address?

Hoping to get your take on this if you don't mind:

Is there a reason the From email address is not the same as the Reply-to email?

The admin already knows which site it's from by the subject so, not sure why the admin email address is coming through too. In this example it was my email address:

email

Also, I'm not sure reply-to always works since some email providers use the From email instead (I experienced this with gmail in fact.)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.