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

[eluser]Glazz[/eluser]
Hello,

I don't know if it is a bug or something but if i have the file email.php or Email.php inside the config folder with my email settings, they never get loaded, since i get the error that i don't have php setup correctly
Quote:Unable to send email using PHP mail(). Your server might not be configured to send mail using this method.

But if i use the
Code:
$this->email->initialize($config);

It works fine.

The config array is the same so the settings are correct, the problem must be on CI side, but mehhh not sure.
#2

[eluser]InsiteFX[/eluser]
I have heard of this before and I think it's a bug in the way the email config file is being loaded,
It has also happened to me before. So now I use switf mail or phpmailer.
#3

[eluser]Glazz[/eluser]
The weird thing is that the file is loaded, but the variables are not being set...

Yeah i was thinking on using Swift mailler, thank you anyway Smile
#4

[eluser]Chathuranga Tennakoon[/eluser]
i have made a blog post to send email with codeigniter using gmail server. please refer the following code.sometimes it may be helpful for you Wink

Code:
<?php
class EmailClass extends CI_Model {

     var $emailUsername="[email protected]";
     var $emailPassword="yourPassword";
     var $emailHost="ssl://smtp.googlemail.com";
     var $emailProtocol="smtp";
     var $emailPort="465";
     var $emaiType="html";
    
    function __construct()
    {
        // Call the Model constructor
        parent::__construct();
        //$this->load->helper("url");
    }
    
    
function sendEmail($emailFrom,$emailTo,$subject,$message){
    
$config = Array(
  'protocol' => $this->emailProtocol,
  'smtp_host' => $this->emailHost,
  'smtp_port' => $this->emailPort,
  'smtp_user' => $this->emailUsername, // change it to yours
  'smtp_pass' => $this->emailPassword, // change it to yours
  'mailtype' => $this->emaiType,
  'charset' => 'iso-8859-1',
  'wordwrap' => TRUE
);
  $this->load->library('email', $config);
  $this->email->set_newline("\r\n");
  $this->email->from($emailFrom); // change it to yours
  $this->email->to($emailTo); // change it to yours
  $this->email->subject($subject);
  $this->email->message($message);

  if($this->email->send())
  {

   return true;

  }
  else
  {
   show_error($this->email->print_debugger());
    
   return false;
  }
  
    
}
    
        
}//class
        
?>
#5

[eluser]Shella[/eluser]
@Glazz

I read that you avoid the bug using

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

I didn't understand where exactly you put this codeline.
Sorry, very newbie into codeigniter.

Thanks!
#6

[eluser]Glazz[/eluser]
[quote author="Shella" date="1337771240"]@Glazz

I read that you avoid the bug using

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

I didn't understand where exactly you put this codeline.
Sorry, very newbie into codeigniter.

Thanks![/quote]

Try that in your controller, instead of having the email class loading the file automatically, that doesn't work properly, you can include the email.php file yourself using include or require something like
Code:
require APPPATH . 'config/email.php';
And this way you can use
Code:
$this->email->initialize($config);

Hope i make it clear for you .
#7

[eluser]Shella[/eluser]
Thank you, it worked well ;-)

Hope this bug is gonna be fixed.

Cheers




Theme © iAndrew 2016 - Forum software by © MyBB