PHP code example of simialbi / yii2-firebasemailer
1. Go to this page and download the library: Download simialbi/yii2-firebasemailer 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/ */
simialbi / yii2-firebasemailer example snippets
return [
// [...]
'components' => [
'firebase' => [
'class' => 'simialbi\yii2\firebasemailer\Mailer',
'firebaseCredentials' => [
'type' => 'service_account',
'project_id' => 'my_app',
'private_key_id' => '4d95db2814a6e057611f7883a9a243f6',
'private_key' => '-----BEGIN PRIVATE KEY-----\n...\n-----END PRIVATE KEY-----\n',
'client_email' => 'firebase-adminsdk-fbsvc@my_app.iam.gserviceaccount.com',
'client_id' => '000000000000000000001',
'auth_uri' => 'https://accounts.google.com/o/oauth2/auth',
'token_uri' => 'https://oauth2.googleapis.com/token',
'auth_provider_x509_cert_url' => 'https://www.googleapis.com/oauth2/v1/certs',
'client_x509_cert_url' => 'https://www.googleapis.com/robot/v1/metadata/x509/firebase-adminsdk-fbsvc%40my_app.iam.gserviceaccount.com',
'universe_domain' => 'googleapis.com'
],
// 'requestOptions' => [
// 'timeout' => 20,
// 'proxy' => 'tcp://proxy.example.com:5100'
// ]
]
]
];
/** @var \simialbi\yii2\firebasemailer\Mailer $firebase */
$firebase = Yii::$app->get('firebase', true);
$message = $firebase->createMessage();
$message
->setSubject('My subject')
->setTextBody('My body\nGreetings')
->setData([
'viewToOpen' => 'my_action',
'actionId' => 123
])
->to(['topic' => 'my_topic'])
->to(['myFirstT0ken', 'my2ndT0ken']) // alternative ;
if ($message->send()) {
echo 'success';
} else {
echo 'failure';
}
$ php composer.phar