-
Notifications
You must be signed in to change notification settings - Fork 52
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Making websites with October CMS - Part 18 - Creating contact form
- Loading branch information
Ivan Doric
committed
Oct 25, 2016
1 parent
146095f
commit 6a50a20
Showing
13 changed files
with
359 additions
and
35 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -15,7 +15,7 @@ | |
| | ||
*/ | ||
|
||
'driver' => 'mail', | ||
'driver' => 'smtp', | ||
|
||
/* | ||
|-------------------------------------------------------------------------- | ||
|
@@ -28,7 +28,7 @@ | |
| | ||
*/ | ||
|
||
'host' => 'smtp.mailgun.org', | ||
'host' => 'smtp.gmail.com', | ||
|
||
/* | ||
|-------------------------------------------------------------------------- | ||
|
@@ -80,7 +80,7 @@ | |
| | ||
*/ | ||
|
||
'username' => null, | ||
'username' => '[email protected]', | ||
|
||
/* | ||
|-------------------------------------------------------------------------- | ||
|
@@ -93,7 +93,7 @@ | |
| | ||
*/ | ||
|
||
'password' => null, | ||
'password' => 'yourpassword', | ||
|
||
/* | ||
|-------------------------------------------------------------------------- | ||
|
@@ -107,7 +107,10 @@ | |
*/ | ||
|
||
'sendmail' => '/usr/sbin/sendmail -bs', | ||
|
||
'to' => [ | ||
'address' => '[email protected]', | ||
'name' => 'Catch all email' | ||
], | ||
/* | ||
|-------------------------------------------------------------------------- | ||
| Mail "Pretend" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
<?php namespace Watchlearn\Contact; | ||
|
||
use System\Classes\PluginBase; | ||
|
||
class Plugin extends PluginBase | ||
{ | ||
public function registerComponents() | ||
{ | ||
return [ | ||
'Watchlearn\Contact\Components\ContactForm' => 'contactform', | ||
]; | ||
} | ||
|
||
public function registerSettings() | ||
{ | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
<?php namespace Watchlearn\Contact\Components; | ||
|
||
use Cms\Classes\ComponentBase; | ||
use Input; | ||
use Mail; | ||
|
||
class ContactForm extends ComponentBase | ||
{ | ||
|
||
public function componentDetails(){ | ||
return [ | ||
'name' => 'Contact Form', | ||
'description' => 'Simple contact form' | ||
]; | ||
} | ||
|
||
|
||
public function onSend(){ | ||
|
||
$vars = ['name' => Input::get('name'), 'email' => Input::get('email'), 'content' => Input::get('content')]; | ||
|
||
Mail::send('watchlearn.contact::mail.message', $vars, function($message) { | ||
|
||
$message->to('[email protected]', 'Admin Person'); | ||
$message->subject('New message from contact form'); | ||
|
||
}); | ||
|
||
} | ||
|
||
} |
Oops, something went wrong.