Welcome Guest, Not a member yet? Register   Sign In
Read from config file
#1

[eluser]HugoA[/eluser]
Hi! I'm trying to read from a mail.php config file the body of an email i want to send, but i dont get any value at all. I'm able to send the email but there is no body.

This is my mail.php file

Code:
<?php  if ( ! defined('BASEPATH')) exit('No direct script access allowed');  
/*
| -------------------------------------------------------------------
| EMAIL CONFING
| -------------------------------------------------------------------
| Configuration of outgoing mail server.
| */  
$config['protocol']='smtp';  
$config['smtp_host']='ssl://smtp.googlemail.com';  
$config['smtp_port']='465';  
$config['smtp_timeout']='30';  
$config['smtp_user']='[email protected]';  
$config['smtp_pass']='password';  
$config['charset']='utf-8';  
$config['newline']="\r\n";  
$config['body'] = 'this is the email body';
/* End of file email.php */  
/* Location: ./system/application/config/email.php */

and this is the method in the controller where i send the email

Code:
function sendMail()
    {
        $this->load->library('email',TRUE);  
        $body= $this->config->item('body','mail');
        $this->email->from('[email protected]','Hugo');  
        $this->email->to("[email protected]");  
        $this->email->subject('A test email from CodeIgniter using Gmail');  
        $this->email->message($this->config->item($body,'email'));  
        $this->email->send();  
    }

what's wrong?
Thanks for your time and help
#2

[eluser]n0xie[/eluser]
Try:
Code:
$this->email->message($this->config->item('body'));
#3

[eluser]frist44[/eluser]
or even simpler:

Code:
$this->email->message(config_item('body'));




Theme © iAndrew 2016 - Forum software by © MyBB