Welcome Guest, Not a member yet? Register   Sign In
sending email using code igniter
#5

(01-15-2015, 08:35 PM)Ben Wrote: I am trying to send email using code igniter and I am not having any luck. I am hosting on a go daddy server. Here is my code. Do I need to create another view? Could there be issues associated with the config file?


PHP Code:
<?php

class Email extends CI_Controller
{
 function 
__construct()
 {
 
parent::Controller();  
 
 
}
 
 function 
index()
 {
 
$config = array( //"Array" changed to "array" 1/15/15
 
 
'protocol' => 'smtp',
 
'smtp_host' => 'ssl://smtp.googlemail.com',
 
'smtp_port' => 465//465
 
'smtp_user' => '[email protected]',
 
'smtp_pass' => 'gmailfb38'
 'mailtype' 
=> 'text',
 
    'charset' => 'iso-8859-1',
 
    'wordwrap' => TRUE
 
);
 
 
$this->load->library('email'$config); //$config
 
 
$this->email->set_newline("\r\n");
 
 
$this->email->from('[email protected]','Ben Abrams');
 
 
$this->email->to('[email protected]');
 
 
$this->email->subject('This is an email test.');
 
 
$this->email->message('It is working.');
 
 
// $this->email->send();
 
 //echo $this->email->print_debugger();
 
 
if($this->email->send())
 {
 echo 
'Your email was sent';
 }
 else
 {
 
show_error($this->email->print_debugger());
 }
 
 }


Okay, first of all, you need to initialise the email class with the new config, not when loading the library: $this->email->initialize($config);

And also you have // $this->email->send(); which sends the email commented out; remove the // and it should work.
Reply


Messages In This Thread
sending email using code igniter - by Ben - 01-15-2015, 08:35 PM
RE: sending email using code igniter - by Rufnex - 01-16-2015, 01:53 AM
RE: sending email using code igniter - by advoor - 01-16-2015, 03:30 AM
RE: sending email using code igniter - by Ben - 01-16-2015, 08:43 AM
RE: sending email using code igniter - by Rufnex - 01-16-2015, 09:23 AM
RE: sending email using code igniter - by Ben - 01-16-2015, 11:58 AM
RE: sending email using code igniter - by Rufnex - 01-16-2015, 03:08 PM
RE: sending email using code igniter - by Ben - 01-16-2015, 08:19 PM



Theme © iAndrew 2016 - Forum software by © MyBB