# Contact form easy solution

**URL:** <https://forum.getkirby.com/t/contact-form-easy-solution/1273>\
**Category:** Questions\
**Tags:** v2\
**Created:** [June 4, 2015, 3:56pm UTC](https://forum.getkirby.com/t/contact-form-easy-solution/1273 "2015-06-04T15:56:16Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![SandroIeva](https://avatars.discourse-cdn.com/v4/letter/s/87869e/32.png) [@SandroIeva](https://forum.getkirby.com/u/SandroIeva)\
**Post date:** [June 4, 2015, 3:56pm UTC](https://forum.getkirby.com/t/contact-form-easy-solution/1273/1 "2015-06-04T15:56:16Z")

</div>

Hello,

i alredy buid my form and input fields, but don’t know how to connect to a php file. Where i have to put the email.php? Or is their a tutorial on create a contact form with kirby??

THX for any help

---

<div class="post-metadata">

**Author:** ![texnixe](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/texnixe/32/5754_2.png) [@texnixe](https://forum.getkirby.com/u/texnixe)\
**Post date:** [June 4, 2015, 4:00pm UTC](https://forum.getkirby.com/t/contact-form-easy-solution/1273/2 "2015-06-04T16:00:03Z")

</div>

Not a tutorial, but a basic example: [https://gist.github.com/bastianallgeier/c396df7923848912393d](https://gist.github.com/bastianallgeier/c396df7923848912393d)

---

<div class="post-metadata">

**Author:** ![SandroIeva](https://avatars.discourse-cdn.com/v4/letter/s/87869e/32.png) [@SandroIeva](https://forum.getkirby.com/u/SandroIeva)\
**Post date:** [June 4, 2015, 4:06pm UTC](https://forum.getkirby.com/t/contact-form-easy-solution/1273/3 "2015-06-04T16:06:53Z")

</div>

Cool! But i don´t check where to put the php files??

---

<div class="post-metadata">

**Author:** ![texnixe](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/texnixe/32/5754_2.png) [@texnixe](https://forum.getkirby.com/u/texnixe)\
**Post date:** [June 4, 2015, 4:13pm UTC](https://forum.getkirby.com/t/contact-form-easy-solution/1273/4 "2015-06-04T16:13:16Z")

</div>

The first one goes into /site/controllers, the second into /site/snippets and the third into /site/templates

---

<div class="post-metadata">

**Author:** ![SandroIeva](https://avatars.discourse-cdn.com/v4/letter/s/87869e/32.png) [@SandroIeva](https://forum.getkirby.com/u/SandroIeva)\
**Post date:** [June 4, 2015, 4:22pm UTC](https://forum.getkirby.com/t/contact-form-easy-solution/1273/5 "2015-06-04T16:22:21Z")

</div>

i see. stupid question 🙂 But it dosn´t work. Can i test this on my local Host?

---

<div class="post-metadata">

**Author:** ![texnixe](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/texnixe/32/5754_2.png) [@texnixe](https://forum.getkirby.com/u/texnixe)\
**Post date:** [June 4, 2015, 4:32pm UTC](https://forum.getkirby.com/t/contact-form-easy-solution/1273/6 "2015-06-04T16:32:07Z")

</div>

This depends on your local host, if you can configure it to send mails …

---

<div class="post-metadata">

**Author:** ![SandroIeva](https://avatars.discourse-cdn.com/v4/letter/s/87869e/32.png) [@SandroIeva](https://forum.getkirby.com/u/SandroIeva)\
**Post date:** [June 4, 2015, 4:38pm UTC](https://forum.getkirby.com/t/contact-form-easy-solution/1273/7 "2015-06-04T16:38:24Z")

</div>

My Form looks like this:

```
	<form id="registrationForm" class="form-horizontal" method="post" >

   <div class="form-group">
    <label class="col-xs-2 control-label">Name</label>
   <div class="col-lg-8 col-md-8">
        <input type="text" class="form-control" name="name" />
    </div>
</div>

<div class="form-group">
    <label class="col-xs-2 control-label">Firma</label>
    <div class="col-lg-8 col-md-8">
        <input type="text" class="form-control" name="Firma" />
    </div>
</div>

<div class="form-group">
    <label class="col-xs-2 control-label">E-Mail</label>
    <div class="col-lg-8 col-md-8">
        <input type="text" class="form-control" name="email" />
    </div>
</div>

<div class="form-group">
    <label class="col-xs-2 control-label">Telefon</label>
    <div class="col-lg-8 col-md-8">
        <input type="text" class="form-control" name="phone" />
    </div>
</div>

<div class="form-group">
    <label class="col-xs-12 col-md-2 col-lg-2 control-label">Rückruf</label>
   <div class="col-lg-8 col-md-2">
        <div class="radio">
            <label>
                <input type="radio" name="call" value="ja" /> JA
            </label>
        </div>
        <div class="radio">
            <label>
                <input type="radio" name="call" value="nein" /> NEIN
            </label>
        </div>
    </div>
</div>

<div class="form-group">
    <label class="col-xs-2 control-label">Nachricht</label>
    <div class="col-lg-8 col-md-8">
        <textarea type="text" class="form-control" name="text" rows="8"/></textarea>
    </div>
</div>

<div class="form-group">
    <div class="col-xs-9 col-md-offset-2">
        <button type="submit" class="btn btn-primary" name="submit" value="submit">SENDEN</button>
    </div>
</div>

```

---

<div class="post-metadata">

**Author:** ![texnixe](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/texnixe/32/5754_2.png) [@texnixe](https://forum.getkirby.com/u/texnixe)\
**Post date:** [June 4, 2015, 4:57pm UTC](https://forum.getkirby.com/t/contact-form-easy-solution/1273/8 "2015-06-04T16:57:56Z")

</div>

The form looks good. What you need to get the example working:

1. A folder called `contact` with a contact.txt in it and a separate subfolder named `thank-you’ with your thank you text.
2. The first file of the example goes into `/site/controllers` and must be named `contact.php`
3. The second file goes into `/site/snippets` and must be names `contactmail.php`
4. The third file goes into `/site/templates` and must be named `contact.php`

Then you can either test on a remote server or you have to find out how to enable sendmail() on your local server

---

<div class="post-metadata">

**Author:** ![SandroIeva](https://avatars.discourse-cdn.com/v4/letter/s/87869e/32.png) [@SandroIeva](https://forum.getkirby.com/u/SandroIeva)\
**Post date:** [June 6, 2015, 7:12pm UTC](https://forum.getkirby.com/t/contact-form-easy-solution/1273/9 "2015-06-06T19:12:02Z")

</div>

IT DOES`T WORK ☹ On my server and on my local host. What can i do??

---

<div class="post-metadata">

**Author:** ![texnixe](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/texnixe/32/5754_2.png) [@texnixe](https://forum.getkirby.com/u/texnixe)\
**Post date:** [June 6, 2015, 7:31pm UTC](https://forum.getkirby.com/t/contact-form-easy-solution/1273/10 "2015-06-06T19:31:40Z")

</div>

Hm, if you have followed the instructions step by step and sendmail() is enabled on your server, this code should work. Have you entered a valid email address in the controller?

```php
$email = email(array(
        'to' => 'youremail@example.com',
        'from' => 'youremail@example.com',
        'subject' => 'New contact request',
        'replyTo' => $data['email'],
        'body' => $body
      ));

```

Have you made sure that sendmail() is enabled on your remote and/or local server (what server are you using locally?)

Do you get any error messages in your server error logs?

---

<div class="post-metadata">

**Author:** ![SandroIeva](https://avatars.discourse-cdn.com/v4/letter/s/87869e/32.png) [@SandroIeva](https://forum.getkirby.com/u/SandroIeva)\
**Post date:** [June 6, 2015, 7:42pm UTC](https://forum.getkirby.com/t/contact-form-easy-solution/1273/11 "2015-06-06T19:42:37Z")

</div>

Yes, i entered my email in there. The only thing i change in the contact controller PHP is the redirect and my email:

```
      $email = email(array(
    'to' => 'mail@sandroieva.com',
    'from' => 'mail@sandroieva.com',
    'subject' => 'New contact request',
    'replyTo' => $data['email'],
    'body' => $body
  ));

  // try to send it and redirect to the
  // thank you page if it worked
  if($email->send()) {
    go('ueber-pretty-check');
  // add the error to the alert list if it failed
  } else {
    $alert = array($email->error());
  }

```

Yes i enabled email, but jam not sure i f it works, but on my server also doesn’t work. Any methods to check if emailing works?

---

<div class="post-metadata">

**Author:** ![SandroIeva](https://avatars.discourse-cdn.com/v4/letter/s/87869e/32.png) [@SandroIeva](https://forum.getkirby.com/u/SandroIeva)\
**Post date:** [June 6, 2015, 8:04pm UTC](https://forum.getkirby.com/t/contact-form-easy-solution/1273/12 "2015-06-06T20:04:16Z")

</div>

when i use a other email php, where i have to put it? so my contact is in a subfolder

---

<div class="post-metadata">

**Author:** ![texnixe](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/texnixe/32/5754_2.png) [@texnixe](https://forum.getkirby.com/u/texnixe)\
**Post date:** [June 6, 2015, 8:13pm UTC](https://forum.getkirby.com/t/contact-form-easy-solution/1273/13 "2015-06-06T20:13:34Z")

</div>

You could check your mail logs, on a UNIX/Mac System that should be in /var/log/mail.log. If you want to use another email.php, the site/plugin folder would be a good place.

Have you also edited your php.ini to enable mail? If you are using Mamp, that would be in conf/php5.x.x/php.ini, I don’t know what software you are using …

---

<div class="post-metadata">

**Author:** ![SandroIeva](https://avatars.discourse-cdn.com/v4/letter/s/87869e/32.png) [@SandroIeva](https://forum.getkirby.com/u/SandroIeva)\
**Post date:** [June 6, 2015, 8:17pm UTC](https://forum.getkirby.com/t/contact-form-easy-solution/1273/14 "2015-06-06T20:17:37Z")

</div>

jes, exactly. I use MAMP on a MAC and change the sendmail\_path. I finde out when i press submit nothing receives, i just echo my data but nothing receives. My contact template looks like this:

```
<div class="row row-fix kontaktbereich">
<div class="col-lg-6 col-md-6">
<form id="registrationForm" class="form-horizontal" method="post" action="email.php">

   <div class="form-group">
    <label class="col-xs-2 control-label">Name</label>
   <div class="col-lg-8 col-md-8">
        <input type="text" id="name" class="form-control" name="name" />
    </div>
</div>

<div class="form-group">
    <label class="col-xs-2 control-label">Firma</label>
    <div class="col-lg-8 col-md-8">
        <input type="text" class="form-control" name="Firma" />
    </div>
</div>

<div class="form-group">
    <label class="col-xs-2 control-label">E-Mail</label>
    <div class="col-lg-8 col-md-8">
        <input type="text" id="email" class="form-control" name="email" />
    </div>
</div>

<div class="form-group">
    <label class="col-xs-2 control-label">Telefon</label>
    <div class="col-lg-8 col-md-8">
        <input type="text" class="form-control" name="phone" />
    </div>
</div>

<div class="form-group">
    <label class="col-xs-12 col-md-2 col-lg-2 control-label">Rückruf</label>
   <div class="col-lg-8 col-md-2">
        <div class="radio">
            <label>
                <input type="radio" name="call" value="ja" /> JA
            </label>
        </div>
        <div class="radio">
            <label>
                <input type="radio" name="call" value="nein" /> NEIN
            </label>
        </div>
    </div>
</div>

<div class="form-group">
    <label class="col-xs-2 control-label">Nachricht</label>
    <div class="col-lg-8 col-md-8">
        <textarea type="text" id="text" class="form-control" name="text" rows="8"/></textarea>
    </div>
</div>

<div class="form-group">
    <div class="col-xs-9 col-md-offset-2">
            <button type="submit" class="btn btn-primary" name="signup" value="submit">Submit</button>
    </div>
</div>

```

\<?php echo $page-\>adresse()-\>kirbytext() ?\>

---

<div class="post-metadata">

**Author:** ![texnixe](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/texnixe/32/5754_2.png) [@texnixe](https://forum.getkirby.com/u/texnixe)\
**Post date:** [June 6, 2015, 8:25pm UTC](https://forum.getkirby.com/t/contact-form-easy-solution/1273/15 "2015-06-06T20:25:18Z")

</div>

I think the best way to check this is by just trying to send an email via php `mail()` command, that way you can test if it works without having to worry if the problem is in your code. I think the problem is rather how or if php works with sendmail.

In my php.ini in Mamp/conf/php5.6.6, I have made the following changes:

```nohighlight
[mail function]
; For Win32 only.
;SMTP = localhost
;smtp_port = 25

; For Win32 only.
;sendmail_from = me@example.com

; For Unix only. You may supply arguments as well (default: "sendmail -t -i").
;sendmail_path =
sendmail_path =/usr/sbin/sendmail -t -i -f mymail@example.com

```

---

<div class="post-metadata">

**Author:** ![SandroIeva](https://avatars.discourse-cdn.com/v4/letter/s/87869e/32.png) [@SandroIeva](https://forum.getkirby.com/u/SandroIeva)\
**Post date:** [June 6, 2015, 8:32pm UTC](https://forum.getkirby.com/t/contact-form-easy-solution/1273/16 "2015-06-06T20:32:03Z")

</div>

yes, did exactly the same changes in php.ini file. Do you use the same form like in bastiansgeier guide?

---

<div class="post-metadata">

**Author:** ![texnixe](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/texnixe/32/5754_2.png) [@texnixe](https://forum.getkirby.com/u/texnixe)\
**Post date:** [June 6, 2015, 8:35pm UTC](https://forum.getkirby.com/t/contact-form-easy-solution/1273/17 "2015-06-06T20:35:46Z")

</div>

Yes, I tested this with the same form (just copied and pasted from the gist into a fresh install) and it works without any problems on my system.

---

<div class="post-metadata">

**Author:** ![SandroIeva](https://avatars.discourse-cdn.com/v4/letter/s/87869e/32.png) [@SandroIeva](https://forum.getkirby.com/u/SandroIeva)\
**Post date:** [June 6, 2015, 8:38pm UTC](https://forum.getkirby.com/t/contact-form-easy-solution/1273/18 "2015-06-06T20:38:22Z")

</div>

maybe because my contact is in a subfolder?

---

<div class="post-metadata">

**Author:** ![texnixe](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/texnixe/32/5754_2.png) [@texnixe](https://forum.getkirby.com/u/texnixe)\
**Post date:** [June 6, 2015, 8:43pm UTC](https://forum.getkirby.com/t/contact-form-easy-solution/1273/19 "2015-06-06T20:43:49Z")

</div>

That shouldn’t make any difference, if the text file in your contact folder is called contact.txt it will look for the template contact.php and the controller contact.php and that’s all that is needed.

---

<div class="post-metadata">

**Author:** ![SandroIeva](https://avatars.discourse-cdn.com/v4/letter/s/87869e/32.png) [@SandroIeva](https://forum.getkirby.com/u/SandroIeva)\
**Post date:** [June 6, 2015, 9:05pm UTC](https://forum.getkirby.com/t/contact-form-easy-solution/1273/20 "2015-06-06T21:05:02Z")

</div>

seems that it doesn´t work with my template. When i use Bastians Template it works, but when i just use my Button does´t work, too

[Next page](https://forum.getkirby.com/t/contact-form-easy-solution/1273.md?page=2)
