Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save sohelrana820/530e0067a4c7d6474239632ffc2d807f to your computer and use it in GitHub Desktop.
Save sohelrana820/530e0067a4c7d6474239632ffc2d807f to your computer and use it in GitHub Desktop.
Configure email transporter in CakePHP in runtime
<?php
Email::configTransport('transporter_name', [
'className' => 'Smtp',
'host' => 'SMTP_HOST',
'port' => 'SMTP_PORT',
'timeout' => 30,
'username' => 'SMTP_USERNAME',
'password' => 'SMTP_PASSWORD',
]);
$email = new Email();
$email->transport('transporter_name');
$email->from('no-replay@example.com')
->to('to@example.com')
->subject('Dummy Subject')
->message('This is a test message')
->send();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment