my controller
<?php
if (!defined('BASEPATH'))
exit('No direct script access allowed');
class Pendientes extends CI_Controller
{
function __construct()
{
parent::__construct();
$this->template->set_layout('layout.php');
$this->load->database();
$this->load->library('grocery_crud');
$this->load->library('email');
$this->load->helper('url');
}
function index()
{
}
function pendientes_v()
{
if ($this->uri->segment(3) == "copyrows")
{
$row_id = $this->uri->segment(4);
$this->copyrows($row_id);
redirect('pendientes/pendientes_v');
}
$this->load->view('layouts/header');
$this->load->view('layouts/menu');
try
{
$crud = new grocery_CRUD();
$crud->set_theme('datatables');
$crud->set_table('pendientes');
$crud->set_subject('Pendientes');
$crud->required_fields(
'nombre', 'email'
);
$crud->columns(
'id', 'nombre', 'email', 'empresa', 'cuit', 'direccion', 'telefono', 'clave'
);
$crud->add_action('Enviar', '', 'pendientes/pendientes_v/copyrows', 'ui-icon-plus');
$output = $crud->render();
$this->load->view('pendientes/pendientes_v', $output);
}
catch (Exception $e)
{
show_error($e->getMessage() . ' --- ' . $e->getTraceAsString());
}
$this->load->view('layouts/footer');
}
function copyrows($id)
{
$this->load->model('standby_model', 'standby');
$this->load->model('cliente_model', 'client');
$this->load->model('customer_model', 'customers');
$clientInfo = $this->client->getInfo($client_id);
$this->email->from('myemail@gmail.com', 'Demo');
$this->email->to($clientInfo['email']);
$this->email->subject('Email Test');
$this->email->message('Hola tu usuario es ' . $clientInfo['email'] . ' y tu contraseña es ' . $clientInfo['clave']);
$this->email->send();
echo $this->email->print_debugger();
$this->customers->insert($id);
$this->standby->delete($id);
}
}
my model cliente_model.php
<?php
class Cliente_Model extends CI_Model{
public function getInfo($client_id){
return array('email' => $email,'clave' => $clave);
}
}
the structure of my table
'id', 'nombre', 'email', 'empresa', 'cuit', 'direccion', 'telefono', 'clave'
errors
Unable to send email using PHP mail(). Your server might not be configured to send mail using this method.
From: "Demo"
Return-Path:
Reply-To: "myemail@gmail.com"
X-Sender: myemail@gmail.com
X-Mailer: CodeIgniter
X-Priority: 3 (Normal)
Message-ID: <51478bcb599c0@gmail.com>
Mime-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: 8bit
=?utf-8?Q?Email_Test?=
Hola tu usuario es y tu contraseña es@gmail.com>@gmail.com>@gmail.com>
A PHP Error was encountered
Severity: Warning
Message: Cannot modify header information - headers already sent by (output started at /home/oscar/public_html/crud/system/core/Exceptions.php:185)
Filename: core/Common.php
Line Number: 438