[eluser]junaids[/eluser]
hi.
i am sendain mail to a user. if a user forgets his password a nw password is sent to his email account.
Code:
<?php
class Forgot extends Controller
{
function Forgot()
{parent::Controller();
$this->load->library('email');
$config['useragent'] = 'websicomm.com';
$config['mailtype'] = 'html';
$config['protocol'] = 'sendmail';
$config['mailpath'] = '/usr/sbin/sendmail';
$config['charset'] = 'iso-8859-1';
$config['wordwrap'] = TRUE;
$this->email->initialize($config);}
function pass()
{
if(!$this->input->post())
{
$email= $this->input->post('email');
$qemail = $this->db->query( "SELECT email FROM `user` WHERE email='" . mysql_real_escape_string( $email ) . "'" );
if( $qemail->num_rows( ) > 0 )
{
$new = '';
for( $i = 1; $i <=7; $i++ )
{
$new .= rand( 1, 9 );
}
$this->db->query( "UPDATE `user` SET password='" . sha1( md5( $new ) ) . "' WHERE email='" . mysql_real_escape_string( $email ) . "'" );
$this->email->message($new);
$this->email->subject('New password is this');
$this->email->from($this->config->item('noreply_address'));
$this->email->reply_to($this->config->item('noreply_address'));
$this->email->to($email);
set_time_limit(0);
ignore_user_abort(true);
$this->email->send();
echo $this->email->print_debugger();
$data['msg']= "Your new password has been sent to your email account";
$this->load->view('forgotpassword!', $data);
}
else
{$data['msg']= "There is no user account against the username you provided!";
$this->load->view('forgotpassword!', $data);}
}
}
}
the password in the database is changed but mail is not recieved by user. any suggestions?