• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
sending mail

#1
[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?

#2
[eluser]junaids[/eluser]
the forgotpassword! view is loaded with the message that ur new password has been sent.

plus the debugger also says that email has been sent

#3
[eluser]The Wizard[/eluser]
are you testing this on the local envoirment?
do you email to hotmail or any free provider? (sometimes emails dont arraive there)

#4
[eluser]junaids[/eluser]
yes its a local environment and i m sending to yahoo

#5
[eluser]The Wizard[/eluser]
try your code on a host, sometimes local envoirments wont send the emails at all.
mine for example is exactly like this. when i put the code on live server, it works
like a charm

try it and report back Smile


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


Users browsing this thread:
1 Guest(s)


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2019 MyBB Group.