Ejemplo n.º 1
0
 private function regconf($email, $username)
 {
     //---------------------------begin email confirmation---------------------------//
     //remove any other pending confirms for this user
     $ect = EmailConfirmTokens::findFirstByUsername($username);
     if ($ect) {
         $ect->delete();
     }
     $token = $this->security->getToken();
     $emailConfToken = new EmailConfirmTokens();
     $emailConfToken->token = $token;
     $emailConfToken->username = $username;
     if ($emailConfToken->create()) {
         $url = 'https://api.sendgrid.com/';
         $user = '******';
         $pass = '******';
         $params = array('api_user' => $user, 'api_key' => $pass, 'to' => $email, 'subject' => 'GetIt! Account Confirmation', 'html' => "<strong>Please use the link below to confirm your account...</strong>\n\t\t\t    \t\t\t\t\t\t<a href=\"globobug.com/hackgt/session/completeReg/{$token}\">Confirm Here!</a>", 'from' => '*****@*****.**');
         $request = $url . 'api/mail.send.json';
         // Generate curl request
         $session = curl_init($request);
         // Tell curl to use HTTP POST
         curl_setopt($session, CURLOPT_POST, true);
         // Tell curl that this is the body of the POST
         curl_setopt($session, CURLOPT_POSTFIELDS, $params);
         // Tell curl not to return headers, but do return the response
         curl_setopt($session, CURLOPT_HEADER, false);
         curl_setopt($session, CURLOPT_RETURNTRANSFER, true);
         // obtain response
         $response = curl_exec($session);
         curl_close($session);
         // print everything out
         print_r($response);
     } else {
         foreach ($emailConfToken->getMessages() as $message) {
             $this->flashSession->error($message);
         }
     }
     //-----------------------------end email confirmation----------------------------//
 }