PHP code example of silverback / yii2-sendinblue
1. Go to this page and download the library: Download silverback/yii2-sendinblue 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/ */
silverback / yii2-sendinblue example snippets
'components' => [
//...
'mailer' => [
'class' => 'yii\sendinblue\transactional\Mailer',
'apikey' => 'your-sedinblue-api-key',
],
//...
]
$viewAttributes = array(
'attribute1' => 'value1',
);
$message = \Yii::$app->mailer->compose('view-name', $viewAttributes);
$message->setFrom( '[email protected] ' );
$message->setSubject( 'Subject' );
$message->setTo( '[email protected] ' );
if ( $message->send() ) {
echo "Sent successfully";
}
$message = \Yii::$app->mailer->compose();
$message->setFrom( '[email protected] ' );
$message->setSubject( 'Subject' );
$message->setTo( '[email protected] ' );
$message->setTextBody( 'test content' );
if ( $message->send() ) {
echo "Sent successfully";
}
$template_id = 1;
$templateAttributes = array(
'attr1' => 'value1',
'attr2' => array(
'subattr1' => 'value2',
'subattr2' => array(
'subsubattr1' => 'value2',
)
),
);
// The class uses Sendiblue templates when the view name is an integer instead of string.
$message = \Yii::$app->mailer->compose( $template_id, $templateAttributes );
$message->setTo( '[email protected] ' );
if ( $message->send() ) {
echo "Sent successfully";
}