| 1234567891011121314151617181920212223242526272829303132333435363738394041424344 |
- <?php
- namespace common\helpers;
- use Mailgun\Mailgun;
- use Yii;
- class Email
- {
- private static $mailKey = '4f64981556009f8e9fc2e112a65d3be3-67bd41c2-4e17cb05';
- /**
- * @param string $email
- * @param string $userName
- * @param string $password
- */
- public static function sendRegistrationEmail(string $email, string $userName, string $password)
- {
- $subject = \Yii::t('app', 'decRegistrationEmailSubject', []);
- $message = \Yii::t('app', 'decRegistrationEmailContent', ['userName' => $userName, 'passWord' => $password]);
- $mailer = Yii::$app->mailer;
- $mailer->useFileTransport = false;
- $response = $mailer->compose()
- ->setFrom(['no.reply.elken@gmail.com' => 'Elken'])
- ->setTo($email)
- ->setSubject($subject)
- ->setHtmlBody($message)
- ->send();
- LoggerTool::debug('sendRegistrationEmail' . sprintf('sendRegistrationEmail: %s', json_encode([$email, $userName, $password, $response])));
- }
- public static function sendEmail(string $email, string $userName, string $password)
- {
- $mg = Mailgun::create(self::$mailKey);
- $mg->messages()->send('ng-frontend-api.elken.com', [
- 'from' => 'Elken <no.reply.elken@gmail.com>',
- 'to' => $email,
- 'subject' => \Yii::t('app', 'decRegistrationEmailSubject', []),
- 'html' => \Yii::t('app', 'decRegistrationEmailContent', ['userName' => $userName, 'passWord' => $password]),
- ]);
- }
- }
|