예제 #1
0
 /**
  * Send a posted contact request to the site admin.
  */
 public function postSendMessage()
 {
     // Make sure the sender's email address is valid.
     if (!($sender_email = Request::post('email', 'email'))) {
         Messenger::error('Please enter a valid email address.');
         return $this->get();
     }
     if (!ReCaptcha::verify()) {
         Messenger::error('You did not correctly enter the captcha code.');
         return $this->get();
     }
     $subject = Configuration::get('contact.subject');
     $body = "\nName: {$_POST['name']}\nEmail: {$sender_email}\nMessage:\n{$_POST['message']}";
     $to_addresses = Configuration::get('contact.to');
     $mailer = new Mailer();
     foreach ($to_addresses as $to) {
         $mailer->to($to);
     }
     $sent = $mailer->from($sender_email)->subject($subject)->message($body)->send();
     if (!$sent) {
         Messenger::error('Your message could not be sent. Please try again later');
         return $this->get();
     } else {
         // Send an email to to have them test for spam.
         if ($auto_responder = Configuration::get('contact.auto_responder')) {
             $auto_responder_mailer = new Mailer();
             $result = $auto_responder_mailer->sendOne($auto_responder, UserModel::loadByEmail($sender_email) ?: new UserModel(array('email' => $sender_email)));
             if ($result && Configuration::get('contact.spam_test')) {
                 // Set the notice.
                 Navigation::redirect('/message', array('msg' => 'spam_test'));
             }
         }
         Navigation::redirect('/message', array('msg' => 'contact_sent'));
     }
 }
예제 #2
0
 public function postReset()
 {
     if (!($email = Request::get('email', 'email'))) {
         Output::error('Invalid email');
     } elseif (!($user = UserModel::loadByEmail($email))) {
         Output::error('User does not exist.');
     }
     $user->sendResetLink();
 }
예제 #3
0
 public function execute()
 {
     // Load the bounce handler.
     require_once HOME_PATH . '/Lightning/Vendor/BounceHandler/src/BounceHandler.php';
     $bounce_handler = new \cfortune\PHPBounceHandler\BounceHandler();
     // Parse the message.
     $bounce_info = $bounce_handler->get_the_facts(file_get_contents('php://stdin'));
     // If this was a message failure.
     if (!empty($bounce_info[0]['recipient']) && preg_match('/5\\.\\d\\.\\d/', $bounce_info[0]['status'])) {
         $email = $bounce_info[0]['recipient'];
         $user = User::loadByEmail($email);
         if (!$user) {
             // Bounced from an unknown recipient, ignore this.
             Tracker::trackEvent('Email Bounced', 0, 0);
             return;
         }
         // Track the bounced event.
         // TODO: we can scan the email for a link to see if we know the message id.
         Tracker::trackEvent('Email Bounced', 0, $user->user_id);
         // Get the last 6 send/bounce events.
         // TODO: Also check for a reactivation email.
         $mail_history = Database::getInstance()->select('tracker_event', array('user_id' => $user->user_id, 'tracker_id' => array('IN', array(Tracker::getTrackerId('Email Sent'), Tracker::getTrackerId('Email Bounced')))), array(), 'ORDER BY date DESC LIMIT 6');
         $bounce_count = 0;
         $bounce_id = Tracker::getTrackerId('Email Bounced');
         foreach ($mail_history as $history) {
             if ($history['tracker_id'] == $bounce_id) {
                 $bounce_count++;
             }
         }
         // If there are two bounced messages, deactivate the user.
         if ($bounce_count >= 2) {
             // TODO: Instead of '1' here, we should have a table like `tracker`
             // that tracks tracker sub_ids by name.
             Tracker::trackEvent('Deactivate User', 1, $user->user_id);
             $user->unsubscribeAll();
         }
     }
 }
예제 #4
0
 /**
  * Send a temporary password.
  *
  * @todo This is not secure. There should be a security question and email should just be a link.
  */
 public function postReset()
 {
     if (!($email = Request::get('email', 'email'))) {
         Output::error('Invalid email');
     } elseif (!($user = UserModel::loadByEmail($email))) {
         Output::error('User does not exist.');
     }
     if ($user->sendResetLink()) {
         Navigation::redirect('message', array('msg' => 'reset'));
     }
 }