This package provides a simple way to use Pulseem for email and SMS sending.
The preferred way to install this extension is through composer.
First add this entry to the repositories
section of your composer.json:
"repositories": [{
...
},{
"type": "git",
"url": "https://github.com/mipotech/yii2-pulseem.git"
},{
...
}],
then add this line:
"mipotech/yii2-pulseem": "dev-master",
to the require
section of your composer.json
file and perform a composer update.
Add the following section to the params file (@app/config/params.php):
return [
...
'pulseem' => [
// Basic config
'password' => '...',
'username' => '...',
//'endpoint' => '...', // Optionally configure a custom endpoint instead of the default
// For email operations (optional)
'fromEmail' => '...',
'fromName' => '...'
// For SMS operations (optional)
'senderPhone' => '...',
],
...
];
That's it. The package is set up and ready to go.
To create an instance of the SDK:
use mipotech\pulseem\PulseemSdk;
$pulseem = new PulseemSdk();
Standard:
$params = [
'htmlBody' => '<p>Body here</p>',
'subject' => 'Testing',
'toEmail' => '[email protected]',
];
$res = $pulseem->sendSingleEmail($params);
Using a Yii2 view:
$params = [
'subject' => 'Testing',
'toEmail' => '[email protected]',
];
$bodyTemplate = '@app/views/emails/customTeplate';
$bodyParams = [
'model' => $model,
'index' => $i,
]
$res = $pulseem->sendSingleEmail($params, $bodyTemplate, $bodyParams);
This type of group email mandates that an array of htmlBodies
be passed as part of $params
.
$params = [
'htmlBodies' => [
'<p>Body here 1</p>',
'<p>Body here 2</p>',
],
'subjects' => [
'Testing 1',
'Testing 2',
],
'toEmails' => [
'[email protected]',
'[email protected]',
],
'toNames' => [
'Test User 1',
'Test User 2',
],
];
$res = $pulseem->sendGroupEmail($params);
This type of group emails support the same two options of either explicitly specifying the htmlBody or using a Yii2 view.
$params = [
'htmlBody' => '<p>Body here</p>',
'subject' => 'Testing',
'toEmails' => [
'[email protected]',
'[email protected]',
],
'toNames' => ['Test 1', 'Test 2'],
];
$res = $pulseem->sendGroupSameEmail($params);
$res = $pulseem->sendSingleSms('+972541112222', 'Testing', [
'delayDeliveryMinutes' => 1, // optional
'externalRef' => '111222', // optional
]);