2017 © Pedro Peláez
 

extension yii2-manual-sendmail-command

Send mail to users from command line for the Yii framework!

image

uguranyum/yii2-manual-sendmail-command

Send mail to users from command line for the Yii framework!

  • Thursday, July 21, 2016
  • by uguranyum
  • Repository
  • 1 Watchers
  • 0 Stars
  • 5 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 5 Versions
  • 0 % Grown

The README.md

iCalender Extension for Yii2 PHP Framework

REQUIREMENTS

Yii2 PHP Framework Yii2 Swiftmailler Extension, (*1)

DOWNLOAD VIA COMPOSER

composer require uguranyum/yii2-manual-sendmail-command

MIGRATE TO DATABASE

yii migrate --migrationPath=@vendor/uguranyum/yii2-manual-sendmail-command/migration --interactive=0

USING EXTENSION

This extension you must be import your mail list to 'mail_list' table. Cloumns are: 'email','special_id','template','json_values' and'create_date'., (*2)

For example you want to reset users password:, (*3)

$users      = Yii::$app->db2->createCommand('SELECT * FROM `users`')->queryAll();

foreach($users as $user)
{
    $sendmail       =   new Sendmail();
    $email          =   $user['email'];
    $special_id     =   $user['id'];
    $template       =   10;             // Your template number. You can make false...
    $create_date    =   time();         // Created user date.
    $password       =   rand(9999999,99999999999); // Create simple random password

    $verification_code    = $sendmail->generateVerificationCode(10); //if you need just help.

    Yii::$app->db2->createCommand()->update('users', [
            'password'          =>  md5($password),              //new md5 password
            'verification_code' =>  $verification_code,          //new verification code
        ], 'id = '.$user['id'])->execute();

    $json_values    =   json_encode(['username' => $user['username'], 'password' => $password ]);

    $sendmail->saveDb($email, $special_id, $template, $json_values, $create_date);
}

This code you are importing users with new password., (*4)

Usage the swiftmailler: Add the following code in your application configuration,, (*5)

return [
    //....
    'components' => [
        'mailer' => [
            'class' => 'yii\swiftmailer\Mailer',
        ],
    ],
];

Configure the mail settings: In the components's section of your common/main-local.php, (*6)

'mail' => [
        'class' => 'yii\swiftmailer\Mailer',
        'viewPath' => '@backend/mail',
        'useFileTransport' => false,//set this property to false to send mails to real email addresses
        //comment the following array to send mail using php's mail function
        'transport' => [
            'class' => 'Swift_SmtpTransport',
            'host' => 'smtp.gmail.com',
            'username' => 'username@gmail.com',
            'password' => 'password',
            'port' => '587',
            'encryption' => 'tls',
                        ],
    ],
],

Use the sample template:, (*7)

path\vendor\uguranyum\yii2-manual-sendmail-command\stemplate\alltemplates.php (all template documents)
Copy to:
path\common\mail\

HOW TO USE

You can use extension in your controller like this:, (*8)

    $sendmail       = new Sendmail();
    $this->saveDb();
    $sendmail->run();
    //$sendmail->turnicateMailList();

The Versions

21/07 2016

dev-master

9999999-dev

Send mail to users from command line for the Yii framework!

  Sources   Download

MIT

The Requires

 

by Ugur

commandline users sendmail

21/07 2016

v2.5

2.5.0.0

Send mail to users from command line for the Yii framework!

  Sources   Download

MIT

The Requires

 

by Ugur

commandline users sendmail

21/07 2016

v2.0

2.0.0.0

Send mail to users from command line for the Yii framework!

  Sources   Download

MIT

The Requires

 

by Ugur

commandline users sendmail

18/07 2016

v1

1.0.0.0

Send mail to users from command line for the Yii framework!

  Sources   Download

MIT

The Requires

 

by Ugur

commandline users sendmail

18/07 2016

0.0.1alpha

0.0.1.0-alpha

Send mail to users from command line for the Yii framework!

  Sources   Download

MIT

The Requires

 

by Ugur

commandline users sendmail