Ejemplo n.º 1
0
 /**
  * @return mixed
  */
 public function send($to, $message, $title = "")
 {
     // Always try to send emails!
     // if (!$this->_is_provider_available()) {
     //    Kohana::$log->add(Log::ERROR, 'The email data source is not currently available. It can be accessed by upgrading to a higher Ushahidi tier.');
     // 		return array(Message_Status::FAILED, FALSE);
     // }
     $provider_options = $this->options();
     $driver = $provider_options['outgoing_type'];
     $options = array('hostname' => $provider_options['outgoing_server'], 'port' => $provider_options['outgoing_port'], 'encryption' => $provider_options['outgoing_security'] != 'none' ? $provider_options['outgoing_security'] : '', 'username' => $provider_options['outgoing_username'], 'password' => $provider_options['outgoing_password']);
     $config = Kohana::$config->load('email');
     $config->set('driver', $driver);
     $config->set('options', $options);
     $tracking_id = self::tracking_id('email');
     $body = View::factory('email/layout');
     $body->message = $message;
     $body->tracking_id = $tracking_id;
     $body->site_url = rtrim(URL::site(), '/');
     $from = $this->from();
     if (!$from) {
         $from = Kohana::$config->load('site.email') ?: '*****@*****.**';
     }
     $from_name = !empty($provider_options['from_name']) ? $provider_options['from_name'] : $from;
     try {
         $result = Email::factory($title, $body->render(), 'text/html')->to($to)->from($from, $from_name)->send();
         return array(Message_Status::SENT, $tracking_id);
     } catch (Exception $e) {
         Kohana::$log->add(Log::ERROR, $e->getMessage());
         // Failed
         return array(Message_Status::FAILED, FALSE);
     }
 }
Ejemplo n.º 2
0
    protected function send_resetpassword($to, $params)
    {
        $site_name = Kohana::$config->load('site.name');
        $site_email = Kohana::$config->load('site.email');
        $client_url = Kohana::$config->load('site.client_url');
        $site_email = $site_email ? $site_email : 'noreply@' . URL::base();
        $subject = $site_name . ': Password reset';
        $message = 'Hello,

A request has been made to reset your account password. To reset your password, you will need to submit this token in order to verify that the request was legitimate.

Your password reset token is ' . $params['token'] . "\n\n";
        if ($client_url) {
            $message .= "Click on the URL below to enter the token and proceed with resetting your password.\n\n";
            $message .= $client_url . '/forgotpassword/confirm/' . urlencode($params['token']);
        }
        $message .= 'Thank you.';
        $email = Email::factory($subject, $message)->to($to)->from($site_email, $site_name)->send();
    }
Ejemplo n.º 3
0
 protected function send_resetpassword($to, $params)
 {
     $site_name = Kohana::$config->load('site.name');
     $site_email = Kohana::$config->load('site.email');
     $multisite_email = Kohana::$config->load('multisite.email');
     $client_url = Kohana::$config->load('site.client_url');
     // @todo make this more robust
     if ($multisite_email) {
         $from_email = $multisite_email;
     } elseif ($site_email) {
         $from_email = $site_email;
     } else {
         $url = Url::createFromServer($_SERVER);
         $host = $url->getHost()->toUnicode();
         $from_email = 'noreply@' . $host;
     }
     $view = View::factory('email/forgot-password');
     $view->site_name = $site_name;
     $view->token = $params['token'];
     $view->client_url = $client_url;
     $message = $view->render();
     $subject = $site_name . ': Password reset';
     $email = Email::factory($subject, $message, 'text/html')->to($to)->from($from_email, $site_name)->send();
 }
Ejemplo n.º 4
0
 /**
  * @return mixed
  */
 public function send($to, $message, $title = "")
 {
     $provider_options = $this->options();
     $driver = $provider_options['outgoing_type'];
     $options = array('hostname' => $provider_options['outgoing_server'], 'port' => $provider_options['outgoing_port'], 'encryption' => $provider_options['outgoing_security'] != 'none' ? $provider_options['outgoing_security'] : '', 'username' => $provider_options['outgoing_username'], 'password' => $provider_options['outgoing_password']);
     $config = Kohana::$config->load('email');
     $config->set('driver', $driver);
     $config->set('options', $options);
     $tracking_id = self::tracking_id('email');
     $body = View::factory('email/layout');
     $body->message = $message;
     $body->tracking_id = $tracking_id;
     $body->site_url = rtrim(URL::site(), '/');
     $from = $this->from();
     $from_name = !empty($provider_options['from_name']) ? $provider_options['from_name'] : $from;
     try {
         $result = Email::factory($title, $body->render(), 'text/html')->to($to)->from($from, $from_name)->send();
         return array(Message_Status::SENT, $tracking_id);
     } catch (Exception $e) {
         Kohana::$log->add(Log::ERROR, $e->getMessage());
         // Failed
         return array(Message_Status::FAILED, FALSE);
     }
 }
Ejemplo n.º 5
0
 protected function send_recover(Model_User &$user)
 {
     $name = $this->dashboard_config->get('name');
     // Search for not disabled hashlink for
     // this user and his current email
     $hashlink = $user->hashlinks->where('email', '=', $user->email)->where('disabled', '=', 0)->order_by('id', 'DESC')->limit(1)->find();
     if (!$hashlink->loaded()) {
         // Disable hashlinks for this user with other emails and create new one:
         $hashlink = $user->disable_hashlinks()->hashlink();
     }
     $message = View::factory('emails/users/recover')->bind('user', $user)->bind('hashlink', $hashlink);
     Email::factory("[{$name}] " . __('Set new password for your account'))->message($message)->from($this->dashboard_config->get('email'), $name)->to($user->email)->send();
 }