Added Google ReCaptcha (Testing).
-
Install composer install
-
config/app.php to the following (password field PMed)
'EmailTransport' => [
'default' => [
'className' => 'Smtp',
// The following keys are used in SMTP transports
'host' => 'ssl://smtp.gmail.com',
'port' => 465,
'timeout' => 30,
'username' => '[email protected]',
'password' => '',
],
],
- go into to the localhost, home page should be have an email address for you to enter, and enter your own email address, it should send you an email soon
- Modelless Form When trying to get data from view without amodel, you will need a modelless form, in this case, emaill address will be passed through
In your project, you will need to create file call "Form" folder in src
and make a form inside like mine
(aka create a php code in /src/Form/EmailForm.php
- Controller You do not need to create a sperate controller like me, but since I dont have any database/page to fall back on, I need a place to fallback on.
You can copy my Email function from /src/controller/emailingcontroller.php
, and include this in the top
use App\Form\EmailForm;
use Cake\Mailer\Email;
Just have a look at the code, pretty easy to understand already
- Templating, you most likely going to use some ctp templating, you can find it in
/src/Template/Email/html
. Therandom.ctp
. Just like any ctp file.