How to include php email activation using php oop syntax..


#1

Hey guys!

I have included the following codes in my register.php to send an email to the person who are registering my site with their email address as follows:

<?php require_once 'core/init.php'; // we have autoloader here if(Input::exists()) { if(Token::check(Input::get('token'))) { $validate = new Validate(); $validation = $validate->check($_POST, array( 'username' => array( 'required' => true, 'min' => 2, 'max' =>20, 'unique' => 'users' ), 'password' => array( 'required' => true, 'min' => 6 ), 'password_again' => array( 'required' => true, 'matches' => 'password' ), 'name' => array( 'required' => true, 'min' => 2, 'max' => 50 ), 'email' => array( 'required' => true, 'min' => 2, 'max' =>30, 'email' =>true ) )); if($validation->passed()) { $user = new User(); $salt = Hash::salt(32); try { $user->create(array( 'username' => Input::get('username'), 'password' => Hash::make(Input::get('password'), $salt), 'salt' => $salt, 'name' => Input::get('name'), 'joined' => date('Y-m-d H:i:s'), 'group' => 0, 'email' => Input::get('email'), 'activated' => 0, 'country' => Input::get('country'), 'token' => Input::get('token'), 'email_code' => Hash::make(Input::get('username', 'date()')) )); $user->email($user->data()->email, 'Activate your account', " Hello " .$user->data()-username .", You need to activate your account, so use the link below: \n\n http://localhost/pianocourse101/activate.php?email=".$user->data()->email."&email_code=".$user->data()->email_code." \n\n -pianocourse101 link "); Session::flash('home', 'You have been registered and can now log in!'); Redirect::to('index.html'); } catch(Exception $e) { die($e->getMessage()); } } else { foreach($validation->errors() as $error) { echo $error, '
'; } } } } I have also added a email function in the user.php file as follows: public function email($to, $subject, $body) { mail($to, $subject, $body, 'From: piano0011@gmail.com'); } I tested it and there was no errors but I am not getting any messages in my gmail account. I have edited the sendmail.ini for the pop3 server as well... I would appreciate any assistance....