If you are working with cakephp 3 and need to send email then this tip help you to send email.
Step 1. Go to your app.php and find EmailTransport and add your SMTP details
1 2 3 4 5 6 7 8 9 10 11 12 13 14 |
'EmailTransport' => [ 'default' => [ 'className' => 'Mail', // The following keys are used in SMTP transports 'host' => 'My_HOST', 'port' => 25, 'timeout' => 30, 'password' => '******', 'client' => null, 'tls' => null, 'url' => env('EMAIL_TRANSPORT_DEFAULT_URL', null), ] ], |
Step 2. Now we can include cakephp default mailer class to send email
1 |
use Cake\Mailer\Email; |
And after this we can create email object where we want to send email and send email
1 2 3 4 5 |
$email = new Email('default'); ->subject('My Subject') ->send('Heloo ..'); |
Done 🙂