1. Go to this page and download the library: Download semhoun/slim-mailer library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
semhoun / slim-mailer example snippets
$containerBuilder = new ContainerBuilder();
$containerBuilder->addDefinitions([
'mailer' => function (ContainerInterface $container) {
$settings = $container->get('settings');
$view = $container->get('view');
$mailer = new \Semhoun\Mailer\Mailer($view, [
'host' => '', // SMTP Host
'port' => '', // SMTP Port
'username' => '', // SMTP Username
'password' => '', // SMTP Password
'protocol' => '' // SSL or TLS
]);
// Set the details of the default sender
$mailer->setDefaultFrom('[email protected]', 'Webmaster');
return $mailer;
}
};
$app->run();
use Semhoun\Mailer\Mailable;
class WelcomeMailable extends Mailable
{
protected $user;
public function __construct($user)
{
$this->user = $user;
}
public function build()
{
$this->setSubject('Welcome to the Team!');
$this->setView('emails/welcome.html.twig', [
'user' => $this->user
]);
return $this;
}
}