1. Go to this page and download the library: Download mattstein/craft-usesend 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/ */
mattstein / craft-usesend example snippets
return [
// Extra attempts after a connection failure, server error, or rate limit.
'retries' => 2,
// Milliseconds between attempts.
'retryDelay' => 200,
// Send embedded (cid:) images as ordinary attachments.
'attachInlineImages' => false,
];
use craft\mail\Mailer;
use craft\mail\Message;
use mattstein\usesend\UseSendTransport;
use yii\base\Event;
use yii\mail\MailEvent;
Event::on(Mailer::class, Mailer::EVENT_BEFORE_SEND, function(MailEvent $event) {
$message = $event->message;
if (!$message instanceof Message || $message->key !== 'account_activation') {
return;
}
$message->setHeader(UseSendTransport::TEMPLATE_ID_HEADER, 'cm8activation');
$message->setHeader(UseSendTransport::VARIABLES_HEADER, json_encode([
'name' => ($message->variables['user'] ?? null)?->friendlyName,
'link' => (string) ($message->variables['link'] ?? ''),
]));
});