Esempio n. 1
1
 private function _send_reset($form)
 {
     $user_name = $form->reset->inputs["name"]->value;
     $user = user::lookup_by_name($user_name);
     if ($user && !empty($user->email)) {
         $user->hash = random::hash();
         $user->save();
         $message = new View("reset_password.html");
         $message->confirm_url = url::abs_site("password/do_reset?key={$user->hash}");
         $message->user = $user;
         Sendmail::factory()->to($user->email)->subject(t("Password Reset Request"))->header("Mime-Version", "1.0")->header("Content-type", "text/html; charset=UTF-8")->message($message->render())->send();
         log::success("user", t("Password reset email sent for user %name", array("name" => $user->name)));
     } else {
         if (!$user) {
             // Don't include the username here until you're sure that it's XSS safe
             log::warning("user", t("Password reset email requested for user %user_name, which does not exist.", array("user_name" => $user_name)));
         } else {
             log::warning("user", t("Password reset failed for %user_name (has no email address on record).", array("user_name" => $user->name)));
         }
     }
     // Always pretend that an email has been sent to avoid leaking
     // information on what user names are actually real.
     message::success(t("Password reset email sent"));
     json::reply(array("result" => "success"));
 }
Esempio n. 2
0
 private function _send_reset()
 {
     $form = $this->_reset_form();
     $valid = $form->validate();
     if ($valid) {
         $user = user::lookup_by_name($form->reset->inputs["name"]->value);
         if (!$user->loaded || empty($user->email)) {
             $form->reset->inputs["name"]->add_error("no_email", 1);
             $valid = false;
         }
     }
     if ($valid) {
         $user->hash = md5(rand());
         $user->save();
         $message = new View("reset_password.html");
         $message->confirm_url = url::abs_site("password/do_reset?key={$user->hash}");
         $message->user = $user;
         Sendmail::factory()->to($user->email)->subject(t("Password Reset Request"))->header("Mime-Version", "1.0")->header("Content-type", "text/html; charset=iso-8859-1")->message($message->render())->send();
         log::success("user", t("Password reset email sent for user %name", array("name" => $user->name)));
     } else {
         // Don't include the username here until you're sure that it's XSS safe
         log::warning("user", "Password reset email requested for bogus user");
     }
     message::success(t("Password reset email sent"));
     print json_encode(array("result" => "success"));
 }
Esempio n. 3
0
 private static function _notify($to, $from, $subject, $item, $text, $headers, $bcc)
 {
     $sendmail = Sendmail::factory();
     $sendmail->to($to)->from($from)->subject($subject);
     if (isset($bcc)) {
         $sendmail->header("bcc", $bcc);
     }
     foreach ($headers as $key => $value) {
         $sendmail->header($key, $value);
     }
     $sendmail->message($text)->send();
     return;
 }
Esempio n. 4
0
 public function send($id)
 {
     access::verify_csrf();
     $user = identity::lookup_user($id);
     $form = user_profile::get_contact_form($user);
     if ($form->validate()) {
         Sendmail::factory()->to($user->email)->subject(html::clean($form->message->subject->value))->header("Mime-Version", "1.0")->header("Content-type", "text/html; charset=iso-8859-1")->reply_to($form->message->reply_to->value)->message(html::purify($form->message->message->value))->send();
         message::success(t("Sent message to %user_name", array("user_name" => $user->display_name())));
         print json_encode(array("result" => "success"));
     } else {
         print json_encode(array("result" => "error", "form" => (string) $form));
     }
 }
Esempio n. 5
0
 public function send($id)
 {
     access::verify_csrf();
     $user = identity::lookup_user($id);
     if (!$this->_can_view_profile_pages($user)) {
         throw new Kohana_404_Exception();
     }
     $form = user_profile::get_contact_form($user);
     if ($form->validate()) {
         Sendmail::factory()->to($user->email)->subject(html::clean($form->message->subject->value))->header("Mime-Version", "1.0")->header("Content-type", "text/html; charset=UTF-8")->reply_to($form->message->reply_to->value)->message(html::purify($form->message->message->value))->send();
         message::success(t("Sent message to %user_name", array("user_name" => $user->display_name())));
         json::reply(array("result" => "success"));
     } else {
         json::reply(array("result" => "error", "html" => (string) $form));
     }
 }
Esempio n. 6
0
 private static function _sendemail($email, $subject, $message)
 {
     Sendmail::factory()->to($email)->subject($subject)->header("Mime-Version", "1.0")->header("Content-type", "text/html; charset=iso-8859-1")->message($message->render())->send();
 }
Esempio n. 7
0
 private static function _notify_subscribers($item, $text, $subject)
 {
     $users = self::get_subscribers($item);
     if (!empty($users)) {
         if (!batch::in_progress()) {
             Sendmail::factory()->to($users)->subject($subject)->header("Mime-Version", "1.0")->header("Content-type", "text/html; charset=utf-8")->message($text)->send();
         } else {
             foreach ($users as $user) {
                 $pending = ORM::factory("pending_notification");
                 $pending->subject = $subject;
                 $pending->text = $text;
                 $pending->email = $user;
                 $pending->save();
             }
         }
     }
 }
Esempio n. 8
0
 private static function _send_message($item, $body)
 {
     $users = self::get_subscribers($item);
     if (!empty($users)) {
         Sendmail::factory()->to($users)->subject($body->subject)->header("Mime-Version", "1.0")->header("Content-type", "text/html; charset=iso-8859-1")->message($body->render())->send();
     }
 }
Esempio n. 9
0
 public function sendemail()
 {
     // Process the data from the form into an email,
     //   then send the email.
     // Copy the data from the email from into a couple of variables.
     $str_emailsubject = Input::instance()->post("email_subject");
     $str_emailtoid = Input::instance()->post("email_to_id");
     $str_emailfrom = Input::instance()->post("email_from");
     $str_emailbody = Input::instance()->post("email_body");
     // Add in some <br> tags to the message body where ever there are line breaks.
     $str_emailbody = str_replace("\n", "\n<br/>", $str_emailbody);
     // Gallery's Sendmail library doesn't allow for custom from addresses,
     //   so add the from email to the beginning of the message body instead.
     $str_emailbody = "Message Sent From " . $str_emailfrom . "\r\n\r\n<br/><br/>" . $str_emailbody;
     // Figure out where the email is going to.
     $str_emailto = "";
     if ($str_emailtoid == -1) {
         // If the email id is "-1" send the message to a pre-determined
         //   owner email address.
         $str_emailto = module::get_var("contactowner", "contact_owner_email");
     } else {
         // or else grab the email from the user table.
         $userDetails = ORM::factory("user")->where("id", $str_emailtoid)->find_all();
         $str_emailto = $userDetails[0]->email;
     }
     // Send the email message.
     Sendmail::factory()->to($str_emailto)->subject($str_emailsubject)->header("Mime-Version", "1.0")->header("Content-type", "text/html; charset=utf-8")->message($str_emailbody)->send();
     // Display a message telling the visitor that their email has been sent.
     $template = new Theme_View("page.html", "Contact");
     $template->content = new View("contactowner_emailform.html");
     $template->content->sendmail_form = t("Your Message Has Been Sent.");
     print $template;
 }
Esempio n. 10
0
 private static function _notify($email, $locale, $item, $text, $subject)
 {
     if (!batch::in_progress()) {
         Sendmail::factory()->to($email)->subject($subject)->header("Mime-Version", "1.0")->header("Content-Type", "text/html; charset=UTF-8")->message($text)->send();
     } else {
         $pending = ORM::factory("pending_notification");
         $pending->subject = $subject;
         $pending->text = $text;
         $pending->email = $email;
         $pending->locale = $locale;
         $pending->save();
     }
 }
 private static function _send_mail($mailto, $subject, $message)
 {
     //Send the notification mail
     $message = nl2br($message);
     return Sendmail::factory()->to($mailto)->subject($subject)->header("Mime-Version", "1.0")->header("Content-type", "text/html; charset=utf-8")->message($message)->send();
 }
Esempio n. 12
0
 public function sendemail()
 {
     // Process the data from the form into an email,
     //   then send the email.
     // Make sure the form was submitted.
     if ($_POST) {
         // Set up some rules to validate the form against.
         $post = new Validation($_POST);
         $post->add_rules('email_from', 'required', 'valid::email');
         $post->add_rules('email_subject', 'required');
         $post->add_rules('email_body', 'required');
         // If the form was filled out properly then...
         if ($post->validate()) {
             // Copy the data from the email form into a couple of variables.
             $str_emailsubject = Input::instance()->post("email_subject");
             $str_emailtoid = Input::instance()->post("email_to_id");
             $str_emailfrom = Input::instance()->post("email_from");
             $str_emailbody = Input::instance()->post("email_body");
             // Add in some <br> tags to the message body where ever there are line breaks.
             $str_emailbody = str_replace("\n", "\n<br/>", $str_emailbody);
             // Gallery's Sendmail library doesn't allow for custom from addresses,
             //   so add the from email to the beginning of the message body instead.
             //   Also add in the admin-defined message header.
             $str_emailbody = module::get_var("contactowner", "contact_owner_header") . "<br/>\r\n" . "Message Sent From " . $str_emailfrom . "<br/>\r\n<br/>\r\n" . $str_emailbody;
             // Figure out where the email is going to.
             $str_emailto = "";
             if ($str_emailtoid == -1) {
                 // If the email id is "-1" send the message to a pre-determined
                 //   owner email address.
                 $str_emailto = module::get_var("contactowner", "contact_owner_email");
             } else {
                 // or else grab the email from the user table.
                 $userDetails = ORM::factory("user")->where("id", "=", $str_emailtoid)->find_all();
                 $str_emailto = $userDetails[0]->email;
             }
             // Send the email message.
             Sendmail::factory()->to($str_emailto)->subject($str_emailsubject)->header("Mime-Version", "1.0")->header("Content-type", "text/html; charset=utf-8")->message($str_emailbody)->send();
             // Display a message telling the visitor that their email has been sent.
             $template = new Theme_View("page.html", "other", "Contact");
             $template->content = new View("contactowner_emailform.html");
             $template->content->sendmail_form = t("Your Message Has Been Sent.");
             print $template;
         } else {
             // Display a message telling the visitor that their email has been not been sent,
             //   along with the reason(s) why.
             $template = new Theme_View("page.html", "other", "Contact");
             $template->content = new View("contactowner_emailform.html");
             $template->content->sendmail_form = t("Your Message Has Not Been Sent.");
             $template->content->sendmail_form = $template->content->sendmail_form . "<br/><br/>" . t("Reason(s):") . "<br/>";
             foreach ($post->errors('form_error_messages') as $error) {
                 $template->content->sendmail_form = $template->content->sendmail_form . " - " . t($error) . "<br/>";
             }
             print $template;
         }
     }
 }
Esempio n. 13
0
 public function sendemail($user_id)
 {
     // Validate the form, then send the actual email.
     // If this page is disabled, show a 404 error.
     if ($user_id == "-1" && module::get_var("contactowner", "contact_owner_link") != true) {
         throw new Kohana_404_Exception();
     } elseif ($user_id >= 0 && module::get_var("contactowner", "contact_user_link") != true) {
         throw new Kohana_404_Exception();
     }
     // Make sure the form submission was valid.
     $form = $this->get_email_form($user_id);
     $valid = $form->validate();
     if ($valid) {
         // Copy the data from the email form into a couple of variables.
         $str_emailsubject = Input::instance()->post("email_subject");
         $str_emailfrom = Input::instance()->post("email_from");
         $str_emailbody = Input::instance()->post("email_body");
         // Add in some <br> tags to the message body where ever there are line breaks.
         $str_emailbody = str_replace("\n", "\n<br/>", $str_emailbody);
         // Gallery's Sendmail library doesn't allow for custom from addresses,
         //   so add the from email to the beginning of the message body instead.
         //   Also add in the admin-defined message header.
         $str_emailbody = module::get_var("contactowner", "contact_owner_header") . "<br/>\r\n" . "Message Sent From " . $str_emailfrom . "<br/>\r\n<br/>\r\n" . $str_emailbody;
         // Figure out where the email is going to.
         $str_emailto = "";
         if ($user_id == -1) {
             // If the email id is "-1" send the message to a pre-determined
             //   owner email address.
             $str_emailto = module::get_var("contactowner", "contact_owner_email");
         } else {
             // or else grab the email from the user table.
             $userDetails = ORM::factory("user")->where("id", "=", $user_id)->find_all();
             $str_emailto = $userDetails[0]->email;
         }
         // Send the email message.
         Sendmail::factory()->to($str_emailto)->subject($str_emailsubject)->header("Mime-Version", "1.0")->header("Content-type", "text/html; charset=utf-8")->message($str_emailbody)->send();
         message::info(t("Your Message Has Been Sent."));
         json::reply(array("result" => "success"));
     } else {
         // Set up and display the actual page.
         json::reply(array("result" => "error", "html" => (string) $form));
     }
 }