Example #1
0
	public static function initialize($delegate, $value, $user="", $pass="", $from=""){
		self::$delegate = $delegate;
		self::$value = $value;
		self::$user = $user;
		self::$pass = $pass;
		self::$from = $from;
	}
Example #2
0
 public static function template_new_gameserver_mail($param, $is_resend = false)
 {
     $param = json_decode(json_encode($param), FALSE);
     $user_name = str_replace('@gameloft.com', '', $_SERVER['REMOTE_USER']);
     $user_name = str_replace('.', ' ', ucfirst($user_name));
     //$cc[] = MAIL_MEX;
     foreach ($param as $key => $value) {
         unset($to);
         unset($cc);
         unset($bcc);
         $to[] = ENVIRONMENT == LOCAL || ENVIRONMENT == BETA ? $_SERVER['REMOTE_USER'] : MAIL_OGI;
         $cc[] = ENVIRONMENT == LOCAL || ENVIRONMENT == BETA ? $_SERVER['REMOTE_USER'] : MAIL_MEX;
         $dolly_users = explode(',', $param->{$key}->dolly_users);
         foreach ($dolly_users as $key2 => $value2) {
             if (array_search($value2, $dolly_users)) {
                 if ($value2 == $param->{$key}->requested_by) {
                     unset($dolly_users[$key2]);
                 } else {
                     $cc[] = $value2;
                 }
             }
         }
         $product = Product::load($param->{$key}->product_id)->to_array();
         $product_name = $product['name'];
         $tpl = $param->{$key};
         $tpl->server_type = $key;
         $tpl->comments = $param->{$key}->comments_ogi;
         $tpl->dolly_users = $param->{$key}->dolly_users;
         //Get email template
         ob_start();
         $subject = '[TUNA][chklst] ' . $param->{$key}->environment . ' ' . $key . ' checklist for ' . $product_name;
         include 'mail_templates/new_gameserver_checklist.php';
         $body = ob_get_contents();
         ob_end_clean();
         $m = new Mail('text/plain');
         $m->from($_SERVER['REMOTE_USER']);
         $m->to(@implode(',', $to));
         $m->cc(@implode(',', $cc));
         $m->bcc(@implode(',', $bcc));
         $m->subject($subject);
         $m->body($body);
         $m->send();
     }
     TunaLog::info_log(__CLASS__, __FUNCTION__, $_SERVER['REMOTE_USER'], '');
 }
Example #3
0
 public static function from($mail, $name = null)
 {
     self::$from = self::format($mail, $name);
 }
 /**
  * @param Mail $mail
  * @throws RuntimeException
  */
 public function tryToSendTheMailOrThrowARuntimeException(Mail $mail)
 {
     $couldNotSent = !mail($mail->to(), $mail->subject(), $mail->content(), 'From: ' . $mail->from());
     if ($couldNotSent) {
         throw new RuntimeException('could not sent the mail' . PHP_EOL . 'values: ' . var_export($mail, true));
     }
 }
Example #5
0
 /**
  * Display and treat the form when the user forgot his password
  */
 public function forgottenPassword()
 {
     $form = new Form(array('id' => 'forgotten-password-form', 'fieldsets' => array('form' => array(new EmailInput(array('name' => 'email', 'required' => true, 'label' => Lang::get($this->_plugin . '.forgotten-pwd-form-email-label')))), 'submits' => array(new SubmitInput(array('name' => 'valid', 'label' => Lang::get($this->_plugin . '.valid-button'))), new ButtonInput(array('name' => 'cancel', 'label' => Lang::get($this->_plugin . '.cancel-button'), 'href' => App::router()->getUri('login'), 'target' => 'dialog')))), 'onsuccess' => '
             app.dialog(app.getUri("reset-password"));
             app.notify("warning", Lang.get("main.forgotten-pwd-sent-email-message"));
         '));
     if (!$form->submitted()) {
         Lang::addKeysToJavascript($this->_plugin . '.forgotten-pwd-sent-email-message');
         return Dialogbox::make(array('title' => Lang::get($this->_plugin . '.forgotten-pwd-form-title'), 'icon' => 'lock-alt', 'page' => $form));
     } else {
         if ($form->check()) {
             $user = User::getByEmail($form->getData('email'));
             if (!$user) {
                 // The user does not exists. For security reasons,
                 // reply the email was successfully sent, after a random delay to work around robots
                 usleep(mt_rand(0, 500) * 100);
                 return $form->response(Form::STATUS_SUCCESS, Lang::get($this->_plugin . '.forgotten-pwd-sent-email-message'));
             }
             try {
                 // The user exists, send an email with a 6 chars random verification code
                 $code = Crypto::generateKey(6);
                 // Register the verification code in the session
                 App::session()->setData('forgottenPassword', array('email' => $form->getData('email'), 'code' => Crypto::aes256Encode($code)));
                 $mail = new Mail();
                 $mail->from(Option::get($this->_plugin . '.mailer-from'), Option::get($this->_plugin . '.mailer-from-name'))->to($form->getData('email'))->subject(Lang::get($this->_plugin . '.reset-pwd-email-title', array('sitename' => Option::get($this->_plugin . '.sitename'))))->title(Lang::get('main.reset-pwd-email-title', array('sitename' => Option::get('main.sitename'))))->content(View::make(Plugin::current()->getView('reset-password-email.tpl'), array('sitename' => Option::get($this->_plugin . '.sitename'), 'code' => $code)))->send();
                 return $form->response(Form::STATUS_SUCCESS, Lang::get($this->_plugin . '.forgotten-pwd-sent-email-message'));
             } catch (\Exception $e) {
                 return $form->response(Form::STATUS_ERROR, DEBUG_MODE ? $e->getMessage() : Lang::get($this->_plugin . '.forgotten-pwd-form-error'));
             }
         }
     }
 }