0
votes

I have a CRUD "clientes" and I added a button "email", when I click on it I would like to send an email with a username and a password

here is my button

$crud->add_action('Email', '', 'pendientes/pendientes_v/enviarmail', 'ui-icon-plus'); 

and then the function in my controller

function copyrows($id)
    {

    $this->load->model('cliente_model', 'client');

    $clientInfo = $this->client->getInfo($client_id);    

    $this->email->from('[email protected]', '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();  
    }

my model cliente_model.php

<?php



    class Cliente_Model extends CI_Model{

    public function getInfo($client_id){
        return array('id' => $cliente_id,'email' => $email,'clave' => $clave);

    }
    }

here the 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: "[email protected]" X-Sender: [email protected] X-Mailer: CodeIgniter X-Priority: 3 (Normal) Message-ID: <[email protected]> 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 [email protected]>@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

I know I am receiving a null value but I can't find the solution, hope someone can help me. thanks in advance!

1
Unfortunately, your server may not be configured to send mail using that method. This can be a real pain to diagnose, but it all depends on what server you have and what else is installed on it. The warning message is because CodeIgniter is sending headers for its normal page after the first error message was already sent. - Jerry
if I type my email I receive it, so I think I am having issues with variables, but I couldnt find the way to solve it yet. - Maru
Check if you've any whitespaces in your controller at the beginning of the file and also make sure that you do not close the php tag of your controller. - Amit Horakeri

1 Answers

0
votes

i had the same problem and it's a hell, i fixed only using php native:

mail();

instead of using CI mail library

maybe it fixes your problem too