Email with Code Igniter

Using your ISP's SMTP server

Create a file system/application/config/email.php with your ISP's SMTP server address:

<?php if (!defined('BASEPATH')) exit('No direct script access allowed');
 
        $config['protocol'] = 'smtp';
        $config['smtp_host'] = 'shawmail.vc.shawcable.net';
 
?>

Using Google's SMTP Server

It requires some specific initialization code:

$config = Array(
    'protocol' => 'smtp',
    'smtp_host' => 'ssl://smtp.googlemail.com',
    'smtp_port' => 465,
    'smtp_user' => 'gmail.login@googlemail.com',
    'smtp_pass' => 'your_password',
);
$this->load->library('email', $config);
$this->email->set_newline("\r\n");

More details: Gmail SMTP using SSL/TLS

Feedback

hello, are you use dokuwiki to power this site?
Minh
Nov 19, 2009
#1
dfgsdfg
sdfg
Apr 5, 2010
#2
zxzzX
ZXhdfuj qyyeq nkluewio dflj
Feb 17, 2011
#3
xvxcvxcv
xcvxv
Feb 25, 2011
#4
koiiiii
poiiiiiiiiii
Feb 25, 2011
#5
gatel
gatel
Mar 17, 2011
#6
this is a lovely, elegant explanation. thank you. :-)
Jawad
Apr 11, 2011
#7
rdykt
rtjkjk
May 3, 2011
#8
surim
surim
May 13, 2011
#9
help me :
&lt;?php
class Email extends CI_Controller{
function __construct(){
parent::__construct();


}
function index(){

$config = Array(
'protocol' => 'smtp',
'smtp_host' => 'ssl://smtp.googlemail.com',
'smtp_port' => 465,
'smtp_user' => 'Iskandar7733@gmail.com',
'smtp_pass' => 'pass',
'mailtype' => 'html',
'charset' => 'utf-8',
'wordwrap' => TRUE
);
$this->load->library('email');
$this->email->initialize($config);
$this->email->set_newline("\r\n");
$this->email->from('Iskandar7733@gmail.com','Iskandar');
$this->email->to('sam.muhammadali@gmail.com');
$this->email->subject('This is an email test');
$this->email->message('It is working. Great');


if($this->email->send()){
echo "Your email was sent. fool.";
}else{
show_error($this->email->print_debugger());
}

}
}
?&gt;
Iskandar Iskandar_7733@mail.ru
Apr 3, 2012
#10
ewerwr
werwer
May 27, 2012
#11
superb
sagar babu
Jun 6, 2013
#12
great work
blueocean developer....
Jul 22, 2013
#13
Thanks, this is the answer which i am looking for, if any one need to send emails using multiple SMTP servers then post is the way, worked for me.
Saqib Ahmad
Feb 14, 2014
#14
good
mahmoud ali
Jun 9, 2014
#15
good
mahmoud ali
Jun 9, 2014
#16