• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Sending EMail From Code Igniter 2.0.1

Hello everyone,

I am new to code igniter as well as this forum. I have been learning CI for past 1 week.. This is my first post in this forum.

Now i want to send mail.. So you people kindly guide me to send mail..

What are the basic steps i should follow?

What are the changes should be done in the Email.php Library file?

Waiting for your reply.. Pls help me..

Thanks & Regards,


Hi Raiser,

first of all welcome to the codeigniter forums!

Regarding your question:
Basically it can't be described more clearly than in the CI userguide:

Btw: you don't to change anything in the email library. What you do is
setting some config items which are passed to the library and there you go.

Thanks for your reply.. This is the first reply i am getting in this forum...

I need to confirm one thing.. Will this mail script work in localhost? Because i am trying in local host only..

This script can work on localhost if you have a mailserver installed.

If you just want to test on localhost you can comment out this line:

And debug:
echo $this->email->print_debugger();

You can also download this free email server tool that I use!

Test Mail Server Tool


@InsiteFX: Nice hint! Setting up Mercury allways seemed to be too much hassle for me,
this one is exactly was I was hoping to find one day Wink

Easy to install and enough functionality for testing purposes. Thank you!

Thanks InsiteFX and LuckyFella73 for replying me...

I have installed the mail server.. What should i do next? i tried with some code but still i got error message only.

My code is,

class Task extends CI_Controller {
        function index()
            $config    =    array(
                        "protocol"     =>     "sendmail",
                        "mailpath"     =>    "/usr/sbin/sendmail",
                        "charset"    =>    "iso-8859-1",
                        "wordwrap"    =>    TRUE
            $this->load->library('email', $config);
            $this->email->from('[email protected]');
            $this->email->to('[email protected]');
            $this->email->subject('Code igniter Test');
            $this->email->message('Test Test Test');
            echo $this->email->print_debugger();

Kindly help me to solve this issue..

I'm wondering the same.
@InsiteFX how did you get this configured? I haven't tried to use a local mail client in quite some time (windows xp era). I had some junky one called PostCast that was good for testing, this one looks perfect! Like @LuckyFella73 said, been looking for something like this for a long time!

Installed it, tried a few different settings in config/email.php, restarted server but no luck yet.

[eluser]daniel ispas[/eluser]
The send email code is good. The problem seems to be with your mail server.

You have to use the email classes smtp config! When I installed it defaulted to smtp port 25

When you start it, it will place an icon in the taskbar right click then options and it will tell you what your smtp port is!


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  

  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2021 MyBB Group.