Welcome Guest, Not a member yet? Register   Sign In
problem in sending email
#1

[eluser]asmaa kamal[/eluser]
i got this error

Quote:( ! ) Fatal error: Call to a member function initialize() on a non-object in C:\wamp\www\t\application\config\email.php on

when putting email configuration in this config/email.php

this is code in file

Code:
<?php  if ( ! defined('BASEPATH')) exit('No direct script access allowed');

$config['protocol'] = 'sendmail';
$config['mailpath'] = '/usr/sbin/sendmail';
$config['charset'] = 'iso-8859-1';
$config['wordwrap'] = TRUE;

$this->email->initialize($config);



?>

and i got the error

Quote:Exit status code: 1
Unable to open a socket to Sendmail. Please check settings.
Unable to send email using PHP Sendmail. Your server might not be configured to send mail using this method.
User-Agent: CodeIgniter
Date: Mon, 6 Feb 2012 15:38:37 +0000
From: "wathbaTeam"
Return-Path:
To: [email protected]
Subject: =?iso-8859-1?Q?lost_password?=
Reply-To: "[email protected]"
X-Sender: [email protected]
X-Mailer: CodeIgniter
X-Priority: 3 (Normal)



when i put this configuration ::: config/email.php


Code:
<?php  if ( ! defined('BASEPATH')) exit('No direct script access allowed');

$config['protocol'] = 'smtp';

$config['smtp_host'] = 'localhost';
$config['smtp_user'] = '[email protected]';
$config['smtp_pass'] = 'myDomain';
$config['validate']=TRUE ;

$config['port'] = 25;
$config['newline'] = "\r\n";
?>

this code in user_model :::

Code:
function reset_password($userEmail){
$this->load->library('email');
$config['protocol'] = 'sendmail';
$config['mailpath'] = '/usr/sbin/sendmail';
$config['charset'] = 'iso-8859-1';
$config['wordwrap'] = TRUE;

$this->email->initialize($config);
$temp_password='';
$length=8;
$i=0;
$characters='0123456789abcdefghijklmnopqrstuvwxyz';
for($i=0;$i<$length;$i++)
{
$maxlength=strlen($characters);
if ($length > $maxlength) {
      $length = $maxlength;
    }
$char = substr($characters, mt_rand(0, $maxlength-1), 1);
  if (!strstr($temp_password, $char)) {
        // no, so it's OK to add it onto the end of whatever we've already got...
        $temp_password .= $char;
}}


$query=$this->db->where('userEmail',$userEmail)->get('users');
foreach($query->result() as $row)
{
$userName=$row->userName;
$userId=$row->userId ;
}
$data=array('temp_password'=>$temp_password );
$this->db->where('userEmail', $userEmail);
$this->db->update('users',$data);
$this->email->from('[email protected]', 'wathbaTeam');
$this->email->to($userEmail);
$this->email->subject('lost password');
$this->email->message("to reset your password please click://localhost/index.php/main/confirm_password_reset/$temp_password ");
$this->email->send();
echo $this->email->print_debugger();

}

the smtp works fine

and i have a running Test Mail Server Tool

any help ?

#2

[eluser]asmaa kamal[/eluser]
controller code ::

Code:
&lt;?php

class Main extends CI_Controller {
function Main()
{
parent::__construct();


$this->load->model('user_model');
$this->load->library('form_validation');
// is it true
if($this->input->cookie('wathba'))
{
redirect('dashboard');}


}

  public function login()
  {
/* if(get_cookie('wathba'))
{
redirect('dashboard');}
*/
  
  $this->form_validation->set_rules('userEmail','email','trim|required|valid_email|callback_check_login');
   $this->form_validation->set_rules('userPassword','password','trim|required|md5');
  
  
if($this->form_validation->run()==TRUE)
  {
  
  
if($this->user_model->Login(array('userEmail'=>$this->input->post('userEmail'),'userPassword'=>$this->input->post('userPassword'))))
  {  redirect('main/login');
  
  
  }
  
  
  
else
   {


    redirect('dashboard');
    
  
  
   }}
  
      
$this->load->view('main/login_form');   }

  function index()
{
  
  $this->load->view('main/main_index');
}
function check_login($userEmail)
{
if ($this->input->post('userPassword'))
{
$user=$this->user_model->GetUsers(array('userEmail'=>$userEmail,'userPassword'=>$this->input->post('userPassword')));
if($user) return true ;
else
{$this->form_validation->set_message('check_login','your useremail/password is invalid.');
return false;
}
}


}
function forgot_password()

{

$data['title']='forgot password' ;
$data['discription']='';
$data['keyword']='';
$data['main_content']='main/forgot_password';
$data['robot']='NOINDEX,NOFOLLOW';
$this->load->view('forgot_view',$data);

}

function password_recovery()
{
$this->form_validation->set_rules('userEmail','Email','trim|required|valid_email|callback_check_db_email');
if($this->form_validation->run())
{

$this->user_model->reset_password($this->input->post('userEmail'));
//$this->password_reset();


$this->load->view('password_reset');
}
else
{
$this->forgot_password();
}


}



function check_db_email()
{
$email_check=$this->user_model->is_email_in_DB($this->input->post('userEmail'));
return $email_check ;

}

}
?&gt;
#3

[eluser]InsiteFX[/eluser]
You need to tell it to use sendmail in your php.ini file!
#4

[eluser]asmaa kamal[/eluser]
how?
#5

[eluser]InsiteFX[/eluser]
Code:
; For Win32 only.
; http://php.net/sendmail-from
sendmail_from = postmaster@localhost

; For Unix only.  You may supply arguments as well (default: "sendmail -t -i").
; http://php.net/sendmail-path
sendmail_path = "\"C:\xampp\sendmail\sendmail.exe\" -t"




Theme © iAndrew 2016 - Forum software by © MyBB