Ejemplo n.º 1
0
Archivo: Mail.php Proyecto: vincium/lot
 public static function send($playerId, $notification)
 {
     $options = [];
     $options['clearSelect'] = true;
     $options['select'][] = \Own\Bus\Player\Data::getList(['id', 'user_id', 'username']);
     $options['select'][] = \Rebond\Core\User\Data::getList(['id', 'email'], 'player_user');
     $options['join'][] = 'core_user player_user ON player_user.id = player.user_id';
     $options['where'][] = 'send_notification_email = 1';
     $options['where'][] = ['player.id = ?', $playerId];
     $player = \Own\Bus\Player\Data::load($options);
     if (!isset($player)) {
         return false;
     }
     // send email
     $app = \Rebond\App::instance();
     $tpl = new Util\Template(Util\Template::MODULE, ['bus', 'notification']);
     $tpl->set('url', 'http://' . \Rebond\Config::getPath('siteUrl'));
     $tpl->set('player', $player);
     $tpl->set('notification', $notification);
     $tplMail = new Util\Template(Util\Template::SITE, ['mail']);
     $tplMail->set('title', Util\Lang::lang('notification'));
     $tplMail->set('site', $app->site()->getTitle());
     $tplMail->set('url', 'http://' . \Rebond\Config::getPath('siteUrl'));
     $tplMail->set('layout', $tpl->render('notification'));
     $message = \Swift_Message::newInstance()->setContentType('text/html')->setSubject($app->site()->getTitle() . ' - ' . Util\Lang::lang('notification'))->setFrom(\Rebond\Config::getMail('email'))->setTo($player->getUser()->getEmail())->setBody($tplMail->render('tpl-default'));
     return Util\Mail::send($message);
 }
Ejemplo n.º 2
0
 public static function send($message)
 {
     if (\Rebond\Config::getMail('type') == 'smtp') {
         $transport = \Swift_SmtpTransport::newInstance(\Rebond\Config::getMail('host'), \Rebond\Config::getMail('port'), \Rebond\Config::getMail('option'))->setUsername(\Rebond\Config::getMail('email'))->setPassword(\Rebond\Config::getMail('password'));
     } else {
         if (\Rebond\Config::getMail('type') == 'mail') {
             $transport = \Swift_MailTransport::newInstance();
         }
     }
     $mailer = \Swift_Mailer::newInstance($transport);
     return $mailer->send($message);
 }
Ejemplo n.º 3
0
 public static function resetPassword($siteTitle, \Rebond\Core\User\Model $user)
 {
     $userSecure = \Rebond\Core\UserSecurity\Service::saveSecure($user->getId(), \Rebond\Core\UserSecurity\Model::RESET);
     $tpl = new Util\Template(Util\Template::SITE, ['mail']);
     $tpl->set('url', \Rebond\Config::getPath('siteUrl'));
     $tpl->set('site', $siteTitle);
     $tpl->set('item', $user);
     $tpl->set('reset', $userSecure->getSecure());
     $tplMail = new Util\Template(Util\Template::SITE, ['mail']);
     $tplMail->set('title', Util\Lang::lang('resetPassword'));
     $tplMail->set('site', $siteTitle);
     $tplMail->set('url', \Rebond\Config::getPath('siteUrl'));
     $tplMail->set('layout', $tpl->render('reset-password'));
     $message = \Swift_Message::newInstance()->setContentType('text/html')->setSubject($siteTitle . ' - ' . Util\Lang::lang('resetPassword'))->setFrom(\Rebond\Config::getMail('email'))->setTo($user->getEmail())->setBody($tplMail->render('tpl-default'));
     return Util\Mail::send($message);
 }
Ejemplo n.º 4
0
 public static function error($siteTitle, $emails, $code, $message, $file, $line)
 {
     $tpl = new Util\Template(Util\Template::MODULE, ['app', 'error']);
     $tpl->set('url', \Rebond\Config::getPath('siteUrl'));
     $tpl->set('site', $siteTitle);
     $tpl->set('code', Util\Code::value($code));
     $tpl->set('message', $message);
     $tpl->set('file', $file);
     $tpl->set('line', $line);
     $tplMail = new Util\Template(Util\Template::SITE, ['mail']);
     $tplMail->set('title', Util\Lang::lang('log'));
     $tplMail->set('site', $siteTitle);
     $tplMail->set('url', \Rebond\Config::getPath('siteUrl'));
     $tplMail->set('layout', $tpl->render('mail'));
     $message = \Swift_Message::newInstance()->setContentType('text/html')->setSubject($siteTitle . ' - ' . Util\Lang::lang('log'))->setFrom(\Rebond\Config::getMail('email'))->setTo($emails)->setBody($tplMail->render('tpl-default'));
     return Util\Mail::send($message);
 }