PHP code example of ereminmdev / yii2-unisendermailer

1. Go to this page and download the library: Download ereminmdev/yii2-unisendermailer 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/ */

    

ereminmdev / yii2-unisendermailer example snippets


return [
    //....
    'components' => [
        'uniMailer' => [
            'class' => 'ereminmdev\yii2\unisendermailer\Mailer',
            'viewPath' => '@common/mail',
            'platform' => 'Yii',
            'apiKey' => '...',
            'listId' => ...,
            'maxSimpleCount' => 0,
            'senderName' => '...',
            'senderEmail' => '...',
            'smsSenderName' => '...',
        ],
    ],
];

Yii::$app->uniMailer->compose('contact/html')
    ->setTo($form->email)
    ->setSubject($form->subject)
    ->send(); // or ->sendEmail();

Yii::$app->uniMailer->compose('contact/html')
    ->setTo($form->phone)
    ->setSubject($form->subject)
    ->setType(Message::TYPE_SMS)
    ->send(); // or ->sendSms();

$mailer = Yii::$app->uniMailer;
// for e-mail
$mailer->senderName = 'Sender Name';
$mailer->senderEmail = '[email protected]';
// for sms
$mailer->smsSenderName = 'Sender';