Exemple #1
0
 public function action_testemail()
 {
     // Create an instance
     if (Auth::check()) {
         $data['user_link'] = 'logout';
         $email = Auth::get_screen_name();
         $data['email'] = $email;
     } else {
         $data['user_link'] = 'login';
     }
     $email = Email::forge();
     // Set the from address
     $email->from('*****@*****.**', 'pscms.local');
     // Set the to address
     $email->to('*****@*****.**', 'You');
     // Set a subject
     $email->subject('This is the subject');
     // Set multiple to addresses
     /*$email->to(array(
     			'*****@*****.**',
     			'*****@*****.**' => 'With a Name',
     		));*/
     // And set the body.
     $email->body('This is my message');
     try {
         $email->send();
     } catch (\EmailValidationFailedException $e) {
         // The validation failed
     } catch (\EmailSendingFailedException $e) {
         // The driver could not send the email
         exit('driver cant send mail');
     }
 }
 public static function sendReservedEMail($id)
 {
     $reservation = Model_Lessontime::find($id);
     // for teacher
     $url = Uri::base() . "teachers/top";
     date_default_timezone_set(Config::get("timezone.timezone")[$reservation->teacher->timezone]);
     $body = View::forge("email/teachers/reserved", ["url" => $url]);
     $body->set("name", $reservation->teacher->firstname);
     $body->set("reservation", $reservation);
     $sendmail = Email::forge("JIS");
     $sendmail->from(Config::get("statics.info_email"), Config::get("statics.info_name"));
     $sendmail->to($reservation->teacher->email);
     $sendmail->subject("Lesson Booking Confirmation / Game-bootcamp");
     $sendmail->html_body(htmlspecialchars_decode($body));
     $sendmail->send();
     // for student
     $url = Uri::base() . "students/top";
     date_default_timezone_set(Config::get("timezone.timezone")[$reservation->student->timezone]);
     $body = View::forge("email/students/reserved", ["url" => $url]);
     $body->set("name", $reservation->student->firstname);
     $body->set("reservation", $reservation);
     $sendmail = Email::forge("JIS");
     $sendmail->from(Config::get("statics.info_email"), Config::get("statics.info_name"));
     $sendmail->to($reservation->student->email);
     $sendmail->subject("Lesson Booking Confirmation / Game-bootcamp");
     $sendmail->html_body(htmlspecialchars_decode($body));
     $sendmail->send();
 }
 /**
  * Send email to group of admin users
  * 
  * @param type $group_name
  * @param type $subject
  * @param type $view
  * @param type $email_data
  * @param type $attachment = Attache a file
  * @param type $theme = theme to load views from
  * @return boolean
  * @throws \Exception
  */
 public static function send_email_to_group($group_name, $subject, $view, $email_data, $attachment = false)
 {
     \Config::load('auto_response_emails', 'auto_response_emails', true);
     $emails = \Config::get('auto_response_emails.' . $group_name . '_emails', false);
     if ($emails == false) {
         $emails = \Config::get('auto_response_emails.default_emails', false);
     }
     $bcc = \Config::get('auto_response_emails.bcc');
     $email = \Email::forge();
     $email->cc($emails);
     if ($bcc) {
         $email->bcc($bcc);
     }
     $email->subject($subject);
     $email->from(\Config::get('auto_response_emails.autoresponder_from_email'), \Config::get('site_title'));
     if ($attachment) {
         $email->attach($attachment);
     }
     $emailView = \Theme::instance()->view('views/' . $view)->set('email_data', $email_data, false);
     $email->html_body($emailView);
     try {
         $email->send();
     } catch (\Exception $e) {
         if (\Fuel::$env == 'development') {
             throw new \Exception($e->getMessage());
         } else {
             return false;
         }
     }
     return true;
 }
 public function action_index()
 {
     $this->template = View::forge("teachers/template");
     $this->template->auth_status = false;
     $this->template->title = "Forgotpassword";
     // login
     if (Input::post("email", null) !== null and Security::check_token()) {
         $email = Input::post('email', null);
         $user = Model_User::find("first", ["where" => [["email", $email]]]);
         if ($user != null) {
             $token = Model_Forgotpasswordtoken::forge();
             $token->user_id = $user->id;
             $token->token = sha1("asadsada23424{$user->email}" . time());
             $token->save();
             $url = Uri::base() . "teachers/forgotpassword/form/{$token->token}";
             $body = View::forge("email/forgotpassword", ["url" => $url]);
             $sendmail = Email::forge("JIS");
             $sendmail->from(Config::get("statics.info_email"), Config::get("statics.info_name"));
             $sendmail->to($email);
             $sendmail->subject("forgot password");
             $sendmail->html_body(htmlspecialchars_decode($body));
             $sendmail->send();
         }
         $view = View::forge("teachers/forgotpassword/sent");
         $this->template->content = $view;
     } else {
         $view = View::forge("teachers/forgotpassword/index");
         $this->template->content = $view;
     }
 }
 /**
  * Sends the instructions to a user's email address.
  *
  * @return bool
  */
 private static function _send_instructions($name, Model_User $user)
 {
     $config_key = null;
     switch ($name) {
         case 'confirmation':
             $config_key = 'confirmable';
             break;
         case 'reset_password':
             $config_key = 'recoverable';
             break;
         case 'unlock':
             $config_key = 'lockable';
             break;
         default:
             throw new \InvalidArgumentException("Invalid instruction: {$name}");
     }
     $mail = \Email::forge();
     $mail->from(\Config::get('email.defaults.from.email'), \Config::get('email.defaults.from.name'));
     $mail->to($user->email);
     $mail->subject(__("warden.mailer.subject.{$name}"));
     $token_name = "{$name}_token";
     $mail->html_body(\View::forge("warden/mailer/{$name}_instructions", array('username' => $user->username, 'uri' => \Uri::create(':url/:token', array('url' => rtrim(\Config::get("warden.{$config_key}.url"), '/'), 'token' => $user->{$token_name})))));
     $mail->priority(\Email::P_HIGH);
     try {
         return $mail->send();
     } catch (\EmailSendingFailedException $ex) {
         logger(\Fuel::L_ERROR, "Warden\\Mailer failed to send {$name} instructions.");
         return false;
     }
 }
 /**
  * ユーザーにメールを送信
  *
  * @para $name メールの識別子 $params 差し込むデータ $to 送り先(指定しなければ langの値を使用) $options Fuel準拠のEmailオプション
  * @access protected
  * @return bool
  * @author kobayasi
  * @author shimma
  */
 public function sendMailByParams($name, $params = array(), $to = null, $options = null)
 {
     Lang::load("email/{$name}");
     $email = Email::forge();
     $email->from(Lang::get('from'), Lang::get('from_name'));
     $email->subject($this->renderTemplate(Lang::get('subject'), $params, false));
     $email->body($this->renderTemplate(Lang::get('body'), $params));
     if (!$to) {
         $to = Lang::get('email');
     }
     $email->to($to);
     if (Lang::get('bcc') != '') {
         $email->bcc(Lang::get('bcc'));
     }
     if (!empty($options)) {
         foreach ($options as $option => $value) {
             if (empty($value)) {
                 continue;
             }
             switch ($option) {
                 case 'bcc':
                     $email->bcc($value);
                     break;
                 case 'reply_to':
                     $email->reply_to($value);
                     break;
                 case 'subject':
                     $email->subject($value);
                     break;
             }
         }
     }
     return $email->send();
 }
Exemple #7
0
 public function create_user($userdata)
 {
     $password = \Arr::get($userdata, 'password', null);
     $email = \Arr::get($userdata, 'email', null);
     if (is_null($password) || is_null($email)) {
         Logger::instance()->log_log_in_attempt(Model_Log_In_Attempt::$ATTEMPT_BAD_CRIDENTIALS, $email);
         throw new LogInFailed(\Lang::get('ethanol.errors.loginInvalid'));
     }
     $user = Auth_Driver::get_core_user($email);
     $security = new Model_User_Security();
     //Generate a salt
     $security->salt = Hasher::instance()->hash(\Date::time(), Random::instance()->random());
     $security->password = Hasher::instance()->hash($password, $security->salt);
     if (\Config::get('ethanol.activate_emails', false)) {
         $keyLength = \Config::get('ethanol.activation_key_length');
         $security->activation_hash = Random::instance()->random($keyLength);
         $user->activated = 0;
         //Send email
         \Package::load('email');
         //Build an array of data that can be passed to the email template
         $emailData = array('email' => $user->email, 'activation_path' => \Str::tr(\Config::get('ethanol.activation_path'), array('key' => $security->activation_hash)));
         $email = \Email::forge()->from(\Config::get('ethanol.activation_email_from'))->to($user->email, $user->username)->subject(\Config::get('ethanol.activation_email_subject'))->html_body(\View::forge('ethanol/activation_email', $emailData))->send();
     } else {
         $user->activated = 1;
         $security->activation_hash = '';
     }
     $user->security = $security;
     $user->save();
     $user->clean_security();
     return $user;
 }
 public function action_submit()
 {
     if (!Security::check_token()) {
         Response::redirect('_404_');
     }
     if (Session::get_flash('name')) {
         $contact = Model_Contact::forge();
         $contact->title = Session::get_flash("title");
         $contact->body = Session::get_flash("body");
         $body = View::forge("email/contact");
         $body->set("name", Session::get_flash('name'));
         $body->set("email", Session::get_flash('email'));
         $body->set("body", Session::get_flash('body'));
         $sendmail = Email::forge("JIS");
         $sendmail->from(Config::get("statics.info_email"), Config::get("statics.info_name"));
         $sendmail->to(Config::get("statics.info_email"));
         $sendmail->subject("We got contact/ Game-bootcamp");
         $sendmail->body($body);
         $sendmail->send();
     }
     $this->template->title = "Contact";
     $this->template->sub = "How can we help you?";
     $view = View::forge("contacts/send");
     $this->template->content = $view;
 }
Exemple #9
0
 public function action_send()
 {
     $data['token_key'] = Config::get('security.csrf_token_key');
     $data['token'] = Security::fetch_token();
     $error = array();
     if (Security::check_token()) {
         $val = Validation::forge();
         $val->add_field('username', 'ユーザID', 'required|max_length[9]');
         $val->add_field('mail', 'メールアドレス', 'required|valid_email');
         if ($val->run()) {
             //受信データの整理
             $username = Input::post('username');
             $email = Input::post('mail');
             //登録ユーザの有無の確認
             $user_count = Model_Users::query()->where('username', $username)->where('email', $email)->count();
             //該当ユーザがいれば
             if ($user_count > 0) {
                 //Authのインスタンス化
                 $auth = Auth::instance();
                 //新しいパスワードの自動発行
                 $repass = $auth->reset_password($username);
                 //送信データの整理
                 $data['fullname'] = Model_Users::query()->select('fullname')->where('username', $username)->get();
                 $data['repass'] = $repass;
                 $data['email'] = $email;
                 $data['anchor'] = 'login';
                 $body = View::forge('login/email/autorepass', $data);
                 //Eメールのインスタンス化
                 $sendmail = Email::forge();
                 //メール情報の設定
                 $sendmail->from('*****@*****.**', '');
                 $sendmail->to($email, $username);
                 $sendmail->subject('パスワードの再発行');
                 $sendmail->html_body($body);
                 //メールの送信
                 $sendmail->send();
                 $view = View::forge('login/success', $data);
                 //該当者0のとき
             } else {
                 $view = View::forge('login/contact', $data);
                 $msg = '該当者が存在しませんでした。';
                 $view->set('msg', $msg);
             }
             //バリデーションエラー
         } else {
             $error = $val->error();
             $view = View::forge('login/contact', $data);
             $view->set_global('error', $error, false);
         }
         //CSRF対策
     } else {
         $view = View::forge('login/contact', $data);
         $msg = 'CSRF対策です';
         $view->set('msg', $msg);
     }
     return $view;
 }
 public function action_recover($hash = null)
 {
     if (Input::Method() === "POST") {
         if ($user = \Model\Auth_User::find_by_email(Input::POST('email'))) {
             // generate a recovery hash
             $hash = \Auth::instance()->hash_password(\Str::random()) . $user->id;
             // and store it in the user profile
             \Auth::update_user(array('lostpassword_hash' => $hash, 'lostpassword_created' => time()), $user->username);
             // send an email out with a reset link
             \Package::load('email');
             $email = \Email::forge();
             $html = 'Your password recovery link <a href="' . Uri::Create('login/recover/' . $hash) . '">Recover My Password!</a>';
             // use a view file to generate the email message
             $email->html_body($html);
             // give it a subject
             $email->subject(\Settings::Get('site_name') . ' Password Recovery');
             // GET ADMIN EMAIL FROM SETTINGS?
             $admin_email = Settings::get('admin_email');
             if (empty($admin_email) === false) {
                 $from = $admin_email;
             } else {
                 $from = 'support@' . str_replace('http:', '', str_replace('/', '', Uri::Base(false)));
             }
             $email->from($from);
             $email->to($user->email, $user->fullname);
             // and off it goes (if all goes well)!
             try {
                 // send the email
                 $email->send();
                 Session::set('success', 'Email has been sent to ' . $user->email . '! Please check your spam folder!');
             } catch (\Exception $e) {
                 Session::Set('error', 'We failed to send the eamil , contact ' . $admin_email);
                 \Response::redirect_back();
             }
         } else {
             Session::Set('error', 'Sorry there is not a matching email!');
         }
     } elseif (empty($hash) === false) {
         $hash = str_replace(Uri::Create('login/recover/'), '', Uri::current());
         $user = substr($hash, 44);
         if ($user = \Model\Auth_User::find_by_id($user)) {
             // do we have this hash for this user, and hasn't it expired yet , must be within 24 hours
             if (isset($user->lostpassword_hash) and $user->lostpassword_hash == $hash and time() - $user->lostpassword_created < 86400) {
                 // invalidate the hash
                 \Auth::update_user(array('lostpassword_hash' => null, 'lostpassword_created' => null), $user->username);
                 // log the user in and go to the profile to change the password
                 if (\Auth::instance()->force_login($user->id)) {
                     Session::Set('current_password', Auth::reset_password($user->username));
                     Response::Redirect(Uri::Create('user/settings'));
                 }
             }
         }
         Session::Set('error', 'Invalid Hash!');
     }
     $this->template->content = View::forge('login/recover');
 }
Exemple #11
0
 public function action_send_verification_email($id, $mailaddress, $key)
 {
     $email = Email::forge();
     $email->from('*****@*****.**', 'Eventual system');
     $email->to($mailaddress, "Eventual system user");
     $email->subject('Your registration in Eventual');
     $mail_text = "'Thank you for registering at eventual.org'\n\t\t     Please, verify your address by clicking this link: " . Uri::create("account/verify/" . $id . "/" . $key . "/");
     $email->body($mail_text);
     $email->send();
 }
Exemple #12
0
 protected function sendmail($data)
 {
     Package::load('email');
     $email = Email::forge();
     $email->from($data['from'], $data['from_name']);
     $email->to($data['to'], $data['to_name']);
     $email->subject($data['subject']);
     $email->body($data['body']);
     $email->send();
 }
Exemple #13
0
 public function action_index()
 {
     $this->template->title = "Remittance Payment";
     $this->template->sub = "Follow the steps below to pay";
     if (isset($this->user)) {
         $data["student"] = Model_User::find("first", ["where" => [["deleted_at", 0], ["id", $this->user->id]]]);
     }
     if (Input::post('action') == 'submit') {
         if (Input::post("pay-method", null) != null && Input::post("refno", null) != null) {
             $checkExist = Model_Payment::find("first", ["where" => [["student_id", Input::post("studentId")], ["paid", Input::post("quarter")], ["status", 0]]]);
             if ($checkExist == NULL) {
                 // save
                 $payment = Model_Payment::forge();
                 $payment->student_id = Input::post("studentId");
                 $payment->pay_method = Input::post("paymethod");
                 $payment->paid_at = Input::post("date");
                 $payment->status = 0;
                 $payment->method = Input::post("pay-method");
                 $payment->ref_no = Input::post("refno");
                 if (Input::post("pay-method") == 1) {
                     $payment->paid = "1111";
                 } else {
                     $payment->paid = Input::post("quarter");
                 }
                 $payment->save();
                 $data["user"] = Model_User::find("first", ["where" => [["id", Input::post("studentId")]]]);
                 $pay = Model_Payment::query()->where('status', 0);
                 $lastID = $pay->max('id');
                 $data["pay"] = Model_Payment::find("first", ["where" => [["id", $lastID]]]);
                 //sending mail
                 $body = View::forge("email/payment", $data);
                 $sendmail = Email::forge("JIS");
                 $sendmail->from(Config::get("statics.info_email"), Config::get("statics.info_name"));
                 $sendmail->to("*****@*****.**");
                 //$sendmail->to("*****@*****.**");
                 $sendmail->subject("Payment / Game-bootcamp");
                 $sendmail->html_body("Dear Admin,<br><br>" . htmlspecialchars_decode($body));
                 $sendmail->send();
                 Response::redirect("/students/top/?success=2");
             } else {
                 Response::redirect("/coursefee/remit/?e=2&g=" . Input::post('paymethod', 0));
             }
         } else {
             Response::redirect("/coursefee/?e=4");
         }
     }
     if (isset($this->user)) {
         $view = View::forge("coursefee/remit", $data);
     } else {
         $view = View::forge("coursefee/remit");
     }
     $this->template->content = $view;
 }
 public function action_index()
 {
     $id = Input::get('id', 0);
     $data['payment'] = Model_Payment::find("all", ["where" => [["id", $id]]]);
     //save
     if (Input::post('action') == 'submit') {
         if (Input::post("payid", null) != null) {
             $payid = Input::post("payid", null);
             $payUp = Model_Payment::find("first", ["where" => [["id", $payid]]]);
             DB::update('payment')->value("status", "1")->where('id', '=', $payid)->execute();
             DB::update('users')->value("charge_html", $payUp->paid)->where('id', '=', $payUp->student_id)->execute();
             $data["user"] = Model_User::find("first", ["where" => [["id", $payUp->student_id]]]);
             $data["pay"] = Model_Payment::find("first", ["where" => [["student_id", $payUp->student_id], ["id", $payUp->id]]]);
             $user = $data["user"];
             //sending mail
             $body = View::forge("email/confirm", $data);
             $sendmail = Email::forge("JIS");
             $sendmail->from(Config::get("statics.info_email"), Config::get("statics.info_name"));
             $sendmail->to($user->email);
             $sendmail->subject("Payment Confirmation / Game-bootcamp");
             $sendmail->html_body("Dear " . $user->firstname . ",<br><br>" . htmlspecialchars_decode($body));
             $sendmail->send();
             Response::redirect("/admin/top/?pay=1");
         } else {
         }
     }
     if (Input::post("paymentID", 0) != 0) {
         $cancel = Model_Payment::find(Input::post("paymentID", 0));
         if ($cancel != null) {
             //save
             $cancel->reason = Input::post("explain", 0);
             $cancel->status = 2;
             $cancel->save();
             $data["cancel"] = Model_Payment::find("first", ["where" => [["id", Input::post("paymentID", 0)]]]);
             $student = $data["cancel"];
             $data["student"] = Model_User::find("first", ["where" => [["id", $student->student_id]]]);
             $stud = $data["student"];
             //sendingmail
             $body = View::forge("email/cancelpayment", $data);
             $sendmail = Email::forge("JIS");
             $sendmail->from(Config::get("statics.info_email"), Config::get("statics.info_name"));
             $sendmail->to($stud->email);
             $sendmail->subject("Denied Payment / Game-bootcamp");
             $sendmail->html_body("Dear " . $stud->firstname . ",<br><br>" . htmlspecialchars_decode($body));
             $sendmail->send();
             Response::redirect("/admin/top/?s=1");
         }
     }
     $view = View::forge("admin/payment/index", $data);
     $this->template->content = $view;
 }
Exemple #15
0
 public function action_view($slug = null)
 {
     is_null($slug) and Response::redirect('blog/post');
     $related = in_array('post', \Config::get('comment')) ? array('published_comments', 'author', 'category') : array('author', 'category');
     $data['post'] = Model_Post::find('first', array('where' => array(array('slug' => $slug)), 'related' => $related));
     if (!$data['post']) {
         Session::set_flash('error', 'Could not find post with slug: ' . $slug);
         Response::redirect('blog/post');
     }
     // Is the user sending a comment? If yes, process it.
     if (Input::method() == 'POST') {
         $val = \Comment\Model_Comment::validate('create');
         if ($val->run()) {
             $comment = \Comment\Model_Comment::forge(array('name' => Input::post('name'), 'email' => Input::post('email'), 'content' => Input::post('content'), 'status' => 'pending', 'post_id' => $data['post']->id));
             if ($comment and $comment->save()) {
                 // Manually loading the Email package
                 \Package::load('email');
                 // Sending an email to the post's author
                 $email = \Email::forge();
                 $email->to($data['post']->author->email, $data['post']->author->username);
                 $email->subject('New comment');
                 $email->body(\View::forge('comment/email', array('comment' => $comment))->render());
                 $email->send();
                 unset($email);
                 if ($data['post']->published_comments) {
                     // Sending an email for all commenters
                     $email = \Email::forge();
                     $emails = array();
                     foreach ($data['post']->published_comments as $published_comment) {
                         $emails[$published_comment->email] = '\'' . $published_comment->name . '\'';
                     }
                     $email->to($emails);
                     $email->subject('New comment');
                     $email->body(\View::forge('comment/email_other', array('comment' => $comment, 'post' => $data['post']), false)->render());
                     $email->send();
                     unset($email);
                 }
                 Session::set_flash('success', e('Your comment has been saved, it will' . ' be reviewed by our administrators'));
             } else {
                 Session::set_flash('error', e('Could not save comment.'));
             }
         } else {
             Session::set_flash('error', $val->error());
         }
     }
     $this->template->title = "Post";
     $this->template->content = View::forge('post/view', $data);
     $this->template->content->set('post_content', $data['post']->content, false);
 }
Exemple #16
0
 public static function sendmail($data)
 {
     Package::load('email');
     $items = array('from_address', 'from_name', 'to_address', 'to_name', 'subject');
     foreach ($items as $item) {
         if (isset($data[$item]) && preg_match('/[\\r\\n]/u', $data[$item]) === 1) {
             throw new EmailValidationFailedException('One or more email headers did not pass validation: ' . $item);
         }
     }
     $email = Email::forge();
     $email->from($data['from_address'], isset($data['from_name']) ? $data['from_name'] : null);
     $email->to($data['to_address'], isset($data['to_name']) ? $data['to_name'] : null);
     $email->subject($data['subject']);
     $email->body($data['body']);
     $email->send();
 }
Exemple #17
0
 public function action_submit()
 {
     if (!Security::check_token()) {
         Response::redirect('_404_');
     }
     if (Session::get_flash('email')) {
         $email = Session::get_flash("email");
         try {
             Auth::create_user($email, Session::get_flash("password"), $email, 10);
             $user = Model_User::find("first", ["where" => [["email", $email]]]);
             if ($user != null) {
                 $user->sex = Session::get_flash("sex");
                 $user->firstname = Session::get_flash("firstname");
                 $user->middlename = Session::get_flash("middlename");
                 $user->lastname = Session::get_flash("lastname");
                 $user->birthday = Session::get_flash("year") . "-" . Session::get_flash("month") . "-" . Session::get_flash("day");
                 $user->google_account = Session::get_flash("google_account");
                 $user->need_reservation_email = Session::get_flash("need_reservation_email");
                 $user->need_news_email = Session::get_flash("need_news_email");
                 $user->timezone = Session::get_flash("timezone");
                 $user->pr = Session::get_flash("pr");
                 $user->educational_background = Session::get_flash("educational_background");
                 $user->trial = Session::get_flash("trial");
                 $user->enchantJS = Session::get_flash("enchantJS");
                 $user->save();
                 // send mail
                 $body = View::forge("email/teachers/signup");
                 $body->set("name", $user->firstname);
                 $body->set("user", $user);
                 $body->set("ymd", explode("-", $user->birthday));
                 $sendmail = Email::forge("JIS");
                 $sendmail->from(Config::get("statics.info_email"), Config::get("statics.info_name"));
                 $sendmail->to($user->email);
                 $sendmail->subject("Welcome Aboard! / Game-bootcamp");
                 $sendmail->html_body(htmlspecialchars_decode($body));
                 $sendmail->send();
             } else {
                 Response::redirect('_404_');
             }
         } catch (Exception $e) {
             Response::redirect('_404_');
         }
     } else {
         Response::redirect('_404_');
     }
     $this->template->content = View::forge('teachers/signup/finish');
 }
Exemple #18
0
 public function action_submit()
 {
     if (!Security::check_token()) {
         Response::redirect('_404_');
     }
     if (Session::get_flash('email')) {
         $email = Session::get_flash("email");
         Auth::create_user($email, Session::get_flash("password"), $email, 1);
         $user = Model_User::find("first", ["where" => [["email", $email]]]);
         if ($user != null) {
             $user->sex = Session::get_flash("sex");
             $user->firstname = Session::get_flash("firstname");
             $user->middlename = Session::get_flash("middlename");
             $user->lastname = Session::get_flash("lastname");
             $user->birthday = Session::get_flash("year") . "-" . Session::get_flash("month") . "-" . Session::get_flash("day");
             $user->google_account = Session::get_flash("google_account");
             $user->need_reservation_email = Session::get_flash("need_reservation_email");
             $user->need_news_email = Session::get_flash("need_news_email");
             $user->timezone = Session::get_flash("timezone");
             $user->place = Session::get_flash("grameen");
             $user->grameen_student = Session::get_flash("grameen_student");
             $user->nationality = Session::get_flash("nationality");
             $user->save();
             // send mail
             $body = View::forge("email/students/signup");
             $body->set("name", $user->firstname);
             $body->set("user", $user);
             $body->set("ymd", explode("-", $user->birthday));
             $sendmail = Email::forge("JIS");
             $sendmail->from(Config::get("statics.info_email"), Config::get("statics.info_name"));
             $sendmail->to($user->email);
             $sendmail->subject("Welcome Aboard! / Game-BootCamp");
             $sendmail->html_body(htmlspecialchars_decode($body));
             $documents = Model_Document::query()->where('type', 1)->where('deleted_at', 0)->limit(1)->get_one();
             if (count($documents) > 0) {
                 $query = Model_Document::find($documents->id);
                 $sendmail->attach(DOCROOT . '/contents/' . $query->path);
             }
             $sendmail->send();
         } else {
             Response::redirect('_404_/?hehe');
         }
     } else {
         Response::redirect('_404_');
     }
     $this->template->content = View::forge('students/signup/finish');
 }
Exemple #19
0
 public function action_apply()
 {
     //POST送信なら
     if (Input::method() == 'POST') {
         //受信データの整理
         $username = Input::post('username');
         $email = Input::post('email');
         //登録ユーザーの有無の確認
         $user_count = Model_User::count(array('where' => array(array('username' => $username), array('email', $email))));
         //該当ユーザーがいれば
         if ($user_count > 0) {
             //ユーザーの特定
             $user = Model_User::find('first', array('where' => array('email' => $email)));
             //リセット(再発行)コードの作成
             $reset = mb_substr($user->last_login, -4);
             //ワンタイムパスワードの作成と保存
             $onepass = md5(time());
             $user->onepass = $onepass;
             $user->save();
             //送信データの整理
             $data['reset'] = $reset;
             $data['onepass'] = $onepass;
             $data['username'] = $username;
             $data['email'] = $email;
             $data['anchor'] = 'user/login/repass/' . $onepass;
             $body = View::forge('user/email/repass', $data);
             //Eメールのインスタンス化
             $sendmail = Email::forge();
             //メール情報の設定
             $sendmail->from('*****@*****.**', 'ameken.com');
             $sendmail->to($email, $username);
             $sendmail->subject('パスワードの再発行');
             $sendmail->html_body($body);
             //メールの送信
             $sendmail->send();
             //再発行案内ページへ移動
             return Model_User::theme('admin/template', 'user/login/repass-info');
             //該当ユーザーがいなければ
         } else {
             //エラー表示
             Session::set_flash('error', '該当者がいません。');
         }
     }
     //テーマの表示
     return Model_User::theme('admin/template', 'user/login/apply');
 }
 public function action_send($Pid = 0)
 {
     $this->action_csrf();
     $val = Validation::forge();
     $val->add('sentence', '通報内容')->add_rule('required');
     $username = Auth::get_screen_name();
     $address = Auth::get_email();
     $problem = Input::post('problem');
     $email = Email::forge();
     $email->from('*****@*****.**');
     $email->to($address);
     $email->subject('投稿ID ' . $Pid . '番に対する「' . $problem . '」の通報がありました。');
     $body = Input::post('sentence');
     $email->body($body);
     if ($val->run()) {
         if (Security::check_token()) {
             try {
                 $email->send();
                 $view = View::forge('problemreport/success');
                 return $view;
             } catch (\EmailValidationFailedException $e) {
                 $view = View::forge('welcome/404');
                 return $view;
             } catch (\EmailSendingFailedException $e) {
             }
         } else {
             $this->error['csrf'] = '「CSRFエラー」です。<br>もう一度最初からアクセスし直してください。。';
             $this->action_csrf();
             $this->action_post($Pid);
             $this->data['categorize'] = Model_Category::query()->where('df', '=', '0')->get();
             $view = View::forge('problemreport/ProblemReport', $this->data);
             $view->set_global('error', $this->error, false);
             return $view;
         }
     } else {
         $this->error = $val->error();
         $this->action_csrf();
         $this->action_post($Pid);
         $this->data['categorize'] = Model_Category::query()->where('df', '=', '0')->get();
         $view = View::forge('problemreport/ProblemReport', $this->data);
         $view->set_global('error', $this->error, false);
         return $view;
     }
 }
Exemple #21
0
 public static function sendmail($mailto, $subject, $data, $template = false)
 {
     $body = isset($data['body']) ? $data['body'] : null;
     $email = \Email::forge();
     $email->from(\Fuel\Core\Config::get('mail_from'), \Fuel\Core\Config::get('mail_from_name'));
     //if is array mail
     $mail_to = array();
     if (is_array($mailto)) {
         foreach ($mailto as $key => $value) {
             $mailto_arr = explode(',', trim($value, ','));
             if (is_array($mailto_arr)) {
                 foreach ($mailto_arr as $k => $v) {
                     if ($v != '' && $v != null) {
                         $mail_to[] = $v;
                     }
                 }
             }
         }
         //remove duplicate email
         if ($mail_to) {
             $mail_to = array_unique($mail_to);
         }
         $email->to($mail_to);
     } else {
         $email->to($mailto);
     }
     $email->subject($subject);
     $email->body($body);
     //use template
     if ($template) {
         $email->body(\View::forge($template, $data));
         //$data is var pass to template
     }
     //if have attach
     //$email->attach(DOCROOT.'my-pic.jpg');
     try {
         $email->send();
         return true;
     } catch (\EmailValidationFailedException $e) {
         Fuel\Core\Log::error('Mail validation: ' . json_encode($mailto));
     } catch (\EmailSendingFailedException $e) {
         Fuel\Core\Log::error('Mail send failed: ' . json_encode($mailto));
     }
 }
 public function send()
 {
     $email = \Email::forge();
     $order = $this->emailData['order'];
     $email->to($order->shipping_email, ucwords($order->shipping_first_name . ' ' . $order->shipping_last_name));
     if ($this->emailData['bcc']) {
         $email->bcc($this->emailData['bcc']);
     }
     $email->subject($this->emailData['site_title'] . ' - Your Order');
     $autoresponder_body = \Theme::instance()->view('views/_email/order_confirmation')->set('emailData', $this->emailData, false);
     $emailHtml = \Theme::instance()->view('views/_email/autoresponder')->set('autoresponder_body', $autoresponder_body);
     $email->html_body($emailHtml);
     try {
         $email->send();
         //\Messages::success('A copy of your request has been sent to ' . $this->emailData['order']['billing_email'] . ' for your own reference.');
     } catch (\EmailValidationFailedException $e) {
         \Messages::error('Error while sending email.');
     } catch (\EmailSendingFailedException $e) {
         \Messages::error('Error while sending email.');
     }
 }
Exemple #23
0
 public function action_do()
 {
     try {
         $this->checkCsrf();
         // 入力チェック
         $val = $this->getEditForm()->validation();
         if (!$val->run()) {
             $this->invalid($val);
         }
         $data = $val->validated();
         // メール通知(サンクス) ****************************************************
         $title = "お問い合わせを承りました";
         $email = Email::forge();
         $email->clear_addresses();
         $email->from(Config::get("mail.account.help.addr"), Config::get("mail.account.help.name"));
         $email->to($data["mail_address"], $data["name"] . "様");
         $email->subject(Config::get("mail.prefix") . $title);
         $body = View_Smarty::forge("mail/contact_complete");
         $body->data = $data;
         $body->contact_type_list = $this->contactType;
         $email->body($body);
         Common::sendmail($email);
         // メール通知(管理者) ****************************************************
         $title = "お問い合わせ";
         $email = Email::forge();
         $email->clear_addresses();
         $email->from($data["mail_address"], $data["name"] . "様");
         $email->to(Config::get("mail.account.help.addr"), Config::get("mail.account.help.name"));
         $email->subject(Config::get("mail.prefix") . $title);
         $body = View_Smarty::forge("mail/contact_complete_admin");
         $body->data = $data;
         $body->contact_type_list = $this->contactType;
         $email->body($body);
         Common::sendmail($email);
         $this->template->content = View_Smarty::forge("contact_complete", $data);
     } catch (Exception $e) {
         $this->error($e);
         $this->action_index();
     }
 }
Exemple #24
0
 public function post_setemail()
 {
     $code = 0;
     $message = "ok";
     $email = Input::post("email", null);
     if ($email != null) {
         $mail = Model_Email::forge();
         $mail->email = $email;
         $mail->save();
         $body = View::forge("email/email");
         $sendmail = Email::forge("JIS");
         $sendmail->from(Config::get("statics.info_email"), Config::get("statics.info_name"));
         $sendmail->to($mail->email);
         $sendmail->subject("Thanks for your interest in our classroom. / Game-bootcamp");
         $sendmail->html_body(htmlspecialchars_decode($body));
         $sendmail->send();
     } else {
         $code = 500;
         $message = "email error.";
     }
     $this->response(array('code' => $code, 'message' => $message));
 }
Exemple #25
0
 public function post_send_message()
 {
     $post = $this->post_data('first_name', 'last_name', 'email', 'mobile', 'message');
     if (strpos($post->email->value, '@') === false) {
         return false;
     }
     $email = Email::forge();
     $email->from('*****@*****.**', "{$post->first_name->value} {$post->last_name->value} ({$post->email->value})");
     $email->to('*****@*****.**', 'Alex Shaffer');
     $email->subject("Contact: {$post->first_name->value} {$post->last_name->value} | {$post->email->value} | {$post->mobile->value}");
     $email->body($post->message->value);
     try {
         $email->send();
     } catch (\EmailValidationFailedException $e) {
         // The validation failed
         return Response::forge(json_encode(array('error' => true, 'error_message' => 'The validation failed')));
     } catch (\EmailSendingFailedException $e) {
         // The driver could not send the email
         return Response::forge(json_encode(array('error' => true, 'error_message' => 'The driver could not send the email')));
     }
     return Response::forge(json_encode(array('success' => true)));
 }
Exemple #26
0
 public function action_reset_password()
 {
     if (\Input::post()) {
         $to = trim(\Input::post('email'));
         $user = \DB::select_array(\Config::get('simpleauth.table_columns', array('*')))->where('email', '=', $to)->from(\Config::get('simpleauth.table_name'))->as_object()->execute(\Config::get('simpleauth.db_connection'))->current();
         $data['password'] = \Auth::reset_password($user->username);
         $val = \Validation::forge();
         $val->add_field('email', 'email', 'required|valid_email');
         if ($val->run()) {
             // Create an instance
             $email = \Email::forge();
             // Set the from address
             $email->from('*****@*****.**', 'Les RHs');
             // Set the to address
             $email->to($to);
             // Set a subject
             $email->subject('New password');
             // And set the body.
             $email->html_body(\View::forge('email/template.twig', $data));
             try {
                 $email->send();
             } catch (\EmailValidationFailedException $e) {
                 // The validation failed
             } catch (\EmailSendingFailedException $e) {
                 // The driver could not send the email
             }
             \Session::set_flash('success', 'A new password has been sent');
             \Response::redirect('/');
         } else {
             // repopulate the email field and give some error text back to the view.
             $data['email'] = $to;
             \Session::set_flash('error', $val->error());
         }
     }
     $data['actions'] = ['back' => ['label' => 'Back', 'url' => 'auth']];
     $this->template->title = "Reset password";
     $this->template->content = \View::forge('auth/password.twig', $data);
 }
 public static function hour()
 {
     $reservations = \Model_Lessontime::find("all", ["where" => [["deleted_at", 0], ["status", 1], ["freetime_at", "<=", time() + 3600], ["freetime_at", ">=", time()]]]);
     foreach ($reservations as $reservation) {
         // for teacher
         $url = "http://game-bootcamp.com/teachers/top";
         $body = \View::forge("email/teachers/reminder_1hour", ["url" => $url]);
         $sendmail = \Email::forge("JIS");
         $sendmail->from(\Config::get("statics.info_email"), \Config::get("statics.info_name"));
         $sendmail->to($reservation->teacher->email);
         $sendmail->subject("Your lesson will start.");
         $sendmail->html_body(htmlspecialchars_decode($body));
         $sendmail->send();
         // for student
         $url = "http://game-bootcamp.com/students/top";
         $body = \View::forge("email/students/reminder_1hour", ["url" => $url]);
         $sendmail = \Email::forge("JIS");
         $sendmail->from(\Config::get("statics.info_email"), \Config::get("statics.info_name"));
         $sendmail->to($reservation->student->email);
         $sendmail->subject("Your lesson will start.");
         $sendmail->html_body(htmlspecialchars_decode($body));
         $sendmail->send();
     }
 }
Exemple #28
0
 /**
  * Change user password
  * 
  * @access public
  * @return void
  */
 public function action_password()
 {
     \View::set_global('title', 'Forgot Password');
     if (\Input::post('forgot')) {
         $val = \User\Controller_Validate::forge('forgot_password');
         if ($val->run()) {
             // Get POST values
             $identity = \Input::post('identity', '');
             if (\Sentry::user_exists($identity)) {
                 try {
                     // reset the password
                     $reset = \Sentry::reset_password($identity);
                     if ($reset) {
                         $customer_email = $reset['email'];
                         // Load email package
                         \Package::load('email');
                         // Load email addresses from config (these will be bcc receivers)
                         \Config::load('auto_response_emails', true);
                         $bcc = \Config::get('autoresponders.forgot_password_emails');
                         if (!$bcc) {
                             $bcc = \Config::get('autoresponders.default_emails');
                         }
                         $settings = \Config::load('autoresponder.db');
                         $email_data = array('site_title' => $settings['company_name'], 'customer_identity' => $identity, 'reset_link' => \Uri::front_create('user/reset_password/' . $reset['link']));
                         $email = \Email::forge();
                         $email->to($customer_email);
                         $email->from(\Config::get('auto_response_emails.autoresponder_from_email'), $settings['company_name']);
                         if ($bcc) {
                             $email->bcc($bcc);
                         }
                         $email->subject($email_data['site_title'] . ' - Forgot Password');
                         $email_html = \Theme::instance()->view('views/_email/forgot_password')->set('email_data', $email_data, false);
                         $email->html_body($email_html);
                         try {
                             $email->send();
                             \Messages::success('You have been sent an email to reset your password.');
                         } catch (\EmailValidationFailedException $e) {
                             \Messages::error('Error while sending email.');
                         } catch (\EmailSendingFailedException $e) {
                             \Messages::error('Error while sending email.');
                         }
                         \Response::redirect(\Input::referrer(\Uri::front_create('/')));
                     } else {
                         \Messages::error('There was a problem while trying to change your password. Please try again.');
                     }
                 } catch (\Sentry\SentryException $e) {
                     // show validation errors
                     //\Messages::error('<h4>There was an error while trying to create user</h4>');
                     $errors = $e->getMessage();
                     \Messages::error($errors);
                 }
             } else {
                 \Messages::error('There doesn`t appear to be an account associated with this email address. Try a different email address or register for a new account on the homepage.');
             }
         } else {
             if ($val->error() != array()) {
                 // show validation errors
                 //\Messages::error('<h4>There was an error while trying to create user</h4>');
                 foreach ($val->error() as $e) {
                     \Messages::error($e->get_message());
                 }
             }
         }
     }
     if (\Input::is_ajax()) {
         echo \Theme::instance()->view($this->view_dir . 'forgot_password');
     } else {
         if (isset($val)) {
             \View::set_global('validation', $val, false);
         }
         \Theme::instance()->set_partial('content', $this->view_dir . 'single_forgot_password');
     }
 }
 public function action_recover($hash = null)
 {
     /*
      * https://myturbotax.intuit.com/account-recovery?offering_id=Intuit.cg.myturbotax&username=daniel.rodas1&locale=en-Us&offering_env=prd&confirmation_id=910855&namespace_id=50000003
      */
     //email use a link
     // was the lostpassword form posted?
     if (\Input::method() == 'POST') {
         // do we have a posted email address?
         if ($email = \Input::post('email')) {
             // do we know this user?
             if ($user = \Model\Auth_User::find_by_email($email)) {
                 // generate a recovery hash
                 $hash = \Auth::instance()->hash_password(\Str::random()) . $user->id;
                 // and store it in the user profile
                 \Auth::update_user(array('lostpassword_hash' => $hash, 'lostpassword_created' => time()), $user->username);
                 \Package::load('email');
                 $email = \Email::forge();
                 $data = array();
                 $hash = Crypt::encode($hash, 'R@nd0mK~Y');
                 $data['url'] = \Uri::create('user/password/recover/' . $hash);
                 $data['user'] = $user;
                 // use a view file to generate the email message
                 $email->html_body(View::forge('user/password/email', $data));
                 // give it a subject
                 $email->subject('RN | WJS Password Recovery');
                 //                    $email->subject(__('user.login.password-recovery'));
                 // add from- and to address
                 //                    $from = \Config::get('application.email-addresses.from.website');
                 //                    $from = array('email' => '*****@*****.**', 'name' => 'RN | Wall Street Journal');
                 //                    $email->from($from['email']);
                 $email->from('*****@*****.**');
                 $email->to($user->email);
                 // and off it goes (if all goes well)!
                 try {
                     // send the email
                     //                        $email->send();
                     \Messages::success('Please check your email for instructions to reset your password');
                     //                        \Messages::success(__('user.login.recovery-email-send'));
                     \Response::redirect('user/password/confirm/' . $user->id);
                 } catch (\EmailValidationFailedException $e) {
                     \Messages::error('INVALID EMAIL !');
                     \Messages::error($e->getMessage());
                     //                        \Messages::error(__('user.login.invalid-email-address'));
                     \Response::redirect_back();
                 } catch (\Exception $e) {
                     // log the error so an administrator can have a look
                     logger(\Fuel::L_ERROR, '*** Error sending email (' . __FILE__ . '#' . __LINE__ . '): ' . $e->getMessage());
                     //                        \Messages::error($e->getMessage());
                     \Messages::error('ERROR SENDING EMAIL !');
                     //                        \Messages::error(__('user.login.error-sending-email'));
                 }
             }
         } else {
             // inform the user and fall through to the form
             \Messages::error(__('user.login.error-missing-email'));
         }
         // inform the user an email is on the way (or not ;-))
         \Messages::info(__('user.login.recovery-email-send'));
         \Response::redirect_back();
     } elseif ($hash !== null) {
         $hash = Crypt::decode($hash, 'R@nd0mK~Y');
         // get the userid from the hash
         $user = substr($hash, 44);
         // and find the user with this id
         if ($user = \Model\Auth_User::find_by_id($user)) {
             // do we have this hash for this user, and hasn't it expired yet (we allow for 24 hours response)?
             if (isset($user->lostpassword_hash) and $user->lostpassword_hash == $hash and time() - $user->lostpassword_created < 86400) {
                 // invalidate the hash
                 \Auth::update_user(array('lostpassword_hash' => null, 'lostpassword_created' => null), $user->username);
                 // log the user in and go to the profile to change the password
                 if (\Auth::instance()->force_login($user->id)) {
                     //                        \Messages::info('LOGGED IN');
                     $tempPass = \Auth::instance()->reset_password($user->username);
                     if ($tempPass) {
                         //                        \Messages::info(__('user.login.password-recovery-accepted'));
                         \Messages::info("Your temporary password is : {$tempPass} ");
                         \Response::redirect('backend/account/index/password');
                     } else {
                         return 'Something went wrong resetting password';
                         // something wrong with the hash
                         //                            \Messages::error(__('user.login.recovery-hash-invalid'));
                         //                            \Response::redirect_back();
                     }
                 }
             }
         }
         // something wrong with the hash
         \Messages::error(__('user.login.recovery-hash-invalid'));
         \Response::redirect_back();
     } else {
         // display the login page
         $this->template->content = View::forge('user/password/recover');
     }
 }
Exemple #30
0
 /**
  * Send email
  *
  * @access public
  * @param  object               $order = Order object
  * @param  array of objects     $products = Products from order
  * @param  string               $type = Type of email to send
  * @return void
  */
 public function send_email($order = false, $products = false, $type = 'job')
 {
     // Send email to user
     \Package::load('email');
     // Load email addresses from config (these will be bcc receivers)
     \Config::load('auto_response_emails', 'autoresponders');
     $bcc = \Config::get('autoresponders.order_emails', false);
     if (!$bcc) {
         $bcc = \Config::get('autoresponders.default_emails', false);
     }
     $email_data = array('order' => $order, 'products' => $products, 'site_title' => \Config::get('site_title'));
     $email = \Email::forge();
     $email->to($order['email'], ucwords($order['first_name'] . ' ' . $order['last_name']));
     if ($bcc) {
         $email->bcc($bcc);
     }
     $email->subject($email_data['site_title'] . ' - Your Order');
     // Set correct email view
     $email_view = $type == 'credits' ? 'order_credits' : 'order';
     $email_html = \Theme::instance()->view('views/_email/' . $email_view)->set('email_data', $email_data, false);
     $email->html_body($email_html);
     try {
         $email->send();
         \Messages::success('A copy of your request has been sent to ' . $order['email'] . ' for your own reference.');
     } catch (\EmailValidationFailedException $e) {
         \Messages::error('Error while sending email.');
     } catch (\EmailSendingFailedException $e) {
         \Messages::error('Error while sending email.');
     }
 }