CodeIgniter From Scratch: Day 3

CodeIgniter From Scratch: Day 3. Sending Emails

Aug 4th in Screencasts by Jeffrey Way

At the request of some of our readers, this week, we'll examine just how easy it is to send emails with attachments using Gmail. With raw PHP, this would be a long and tedious task. However, with CodeIgniter, it's a cinch! I'll show you how in this eighteen minute video tutorial.

PG

Author: Jeffrey Way

Hi, I'm Jeff. I'm the editor of Nettuts+, and the Site Manager of Theme Forest. I spend too much time in front of the computer and find myself telling my fiance', "We'll go in 5 minutes!" far too often. I just can't go out to dinner while I'm still producing FireBug errors...drives me crazy. During my free time, I sporadically write articles for my own personal blog. If it will keep you in the good graces of the church, follow us on Twitter.

Catch Up

Day 3


Related Posts

Check out some more great tutorials and articles that you might like

Enjoy this Post?

Your vote will help us grow this site and provide even more awesomeness

Plus Members

Source Files, Bonus Tutorials and
More for $9 a month for all TUTS+
sites in one subscription.

Join Now

User Comments

( ADD YOURS )
  1. PG

    Jeffrey Way August 4th

    Shoot – there seems to be an audio/video sync issue. May have to upload a new version shortly.

    ( Reply )
      1. PG

        Jeffrey Way August 4th

        Uploading the replacement now.

  2. PG

    Gonzalo August 4th

    Thank you very much for your tutorials. Is there any chance that you put the code, too? In the previous tutorials the code was incomplete or had some errors, it would be nice if you could check that out. Thanks in advance! :)

    ( Reply )
    1. PG

      Jeffrey Way August 4th

      What errors did it have? I attach the exact files that I use when recording the screencast. The code is available if you click the big “Download” link.

      ( Reply )
  3. PG

    adrusi August 4th

    OMG!!! you can’t stop these great CI tuts!!!

    ( Reply )
  4. PG

    Jermaine Hercules August 4th

    I have been trying to send email with php all day and now this greate timing

    ( Reply )
    1. PG

      Jermaine Hercules August 4th

      keep up the good work jeff

      ( Reply )
      1. PG

        Jeffrey Way August 4th

        Thanks, Jermaine! Let me know if you have any questions.

  5. FINALLY! Been waiting for this for quite some time now. Keep em coming!

    ( Reply )
  6. PG

    Mike August 4th

    Interesting enough video, but how does it relate to the previous two? We’ve seen the very basics of creating page views, but nothing on actually pulling a site together and adding content to it, and now all of a sudden we are emailing users and allowing them to upload files!

    Please, some kind of logical progression would be much more useful.

    ( Reply )
    1. PG

      Jeff August 4th

      I did it this way on purpose. CodeIgniter isn’t hugely complicated. If you’re familiar with basic HTML and php, you should be able to follow along just fine.

      ( Reply )
      1. PG

        Mike August 4th

        I can follow along no problem, it just seems to me that it would make much more sense to have some kind of basic site before we start emailing users and letting them upload files.

    2. PG

      Tim August 5th

      I think the idea is to learn the skills then pull them all in together at the end.

      ( Reply )
    3. PG

      Cecily August 5th

      I agree with Mike. Some people can learn by being shown some seemingly disconnected lessons and then have them strung together at the end, but others learn better when lessons are constructed progressively. I really appreciate the work you’ve done thus far – it’s increased my basic understanding of CI by tenfold – but I also wonder if I’m going to be stumped at the end because I don’t quite understand how or why all the pieces fit together.

      That said, keep up the great work. This series is why I keep my tutsplus subscription.

      ( Reply )
  7. PG

    Muhammad Adnan August 4th

    jeffrey is a good teacher , i like his videos .

    keep it up.

    ( Reply )
  8. PG

    Matthew August 4th

    Digging these codeigniter tuts! Can’t get enough

    ( Reply )
  9. PG

    Imamu Hunter August 4th

    man I love these videos. I’m taking a step back so I can fully learn php before I start using a framework but I learn so much on this site.

    ( Reply )
    1. PG

      Jeffrey Way August 4th

      Glad you’re enjoying them! :)

      ( Reply )
  10. PG

    DemoGeek August 4th

    Email.php under Config is something new to me…that should be the way to go to manage the code better. It would certainly help if you can zoom out the code a little bit so people can see better.

    ( Reply )
    1. PG

      Jeffrey Way August 4th

      Zoom out? Not sure I understand. Do you mean zoom in? Are you watching in full screen?

      ( Reply )
  11. PG

    Jason August 4th

    I’m trying to learn CodeIgniter, and these tutorials are a huge help!

    One question: When you copied the email configuration to the config/email.php file, couldn’t you have just left those lines as they were rather than individually naming each key and copying the values, etc?

    Or is that just a best-practice sort of thing for config files..?

    ( Reply )
    1. PG

      Roeland September 11th

      I was wondering the same thing.

      ( Reply )
  12. PG

    Kyle August 4th

    Nice job Jeff. I am loving this CI series.

    Keep em coming!!!!

    ( Reply )
  13. PG

    Niklas August 4th

    Just want to thank you for these videos, very good work on a very interesting framework. Keep them comming! :)

    ( Reply )
  14. PG

    Thomas Keller August 4th

    This series is one of the best on nettuts, thanks for this!

    Now, I am waiting for more on models, as I want to have a database with two related tables modelled…. :)

    Keep up the good work!

    ( Reply )
  15. PG

    Joseph Wilson August 4th

    PLEASE DON’T STOP THESE!!!!!

    I hate it when some of these great tutorial series just…stop. It’d be great (like, super GREAT) if this one ran the whole distance. ;)

    You guys are doing an incredible job, here! Keep up the *incredible* work!

    BTW, Jeff, thanks for listening to us. Your videos are amazing.

    ( Reply )
    1. PG

      Jeffrey Way August 4th

      I’ll commit to at least 10. But hopefully more. :)

      ( Reply )
      1. PG

        Shane August 5th

        Great stuff!!!

  16. PG

    Jon Piehl August 4th

    I agree with Mike. It would make more sense to follow a logical progression rather than jumping around to different topics. For instance, day 2 was about getting info from a database, day 3 should have been about inserting info into a database. Complete a topic before moving on. But don’t get me wrong, I love these tuts and I’m learning so much. Keep them coming!

    ( Reply )
  17. PG

    IgnacioRV August 4th

    Thanks Jeff for another useful screencast

    Keep the good work and don’t even think about not continuing this series (you don’t have the feel… they ARE popular =P )…

    ( Reply )
  18. PG

    Brad Madigan August 4th

    Hi Jeff, this series is really giving me a great resource for possibly moving one of my applications to the CI framework.

    I do have a suggestion however, in your tutorial you mentioned that you may or may not use the attachment. If you could, I would be interested in seeing how to handle both HTML and Plain Text versions of an email.

    Thanks again. Great series!

    ( Reply )
    1. PG

      Jon Piehl August 5th

      I would like to know how to handle both HTML and Plain Text emails as well. Thanks!

      ( Reply )
  19. PG

    Cesar August 4th

    Hi Jeff, I love ALL your tutorials. I’ve learned a lot!!!!!

    No offense… BUT PLEASE!!!!!! Stop making so many noises with your mouth!!!!!!

    Again.. Thanks.

    ( Reply )
  20. PG

    lawrence77 August 4th

    Jeff the clarity of this is so cool…..
    So continue with this clarity…;)

    And the password of that nettutstutorials @ gmail.com

    Is didnt changed, unfortunately i login into that account and see 3 mails….. :D
    change it quickly, before others do… :P

    ( Reply )
    1. PG

      Jeffrey Way August 4th

      Oh I don’t really care about that account. I’ll just create a new one. :)

      ( Reply )
      1. PG

        lawrence77 August 5th

        Oops someone change that password…. :cry:

  21. PG

    Mike McMullan August 4th

    Hey Jeff,

    Great Job on this CI video series. I recently did a site with CI, you’ve shown me some better ways I should of done things. I don’t know If you have planned on doing this but, it would be great if you did a video about how to make a Members Area suing CI.

    Keep up the great work.

    ( Reply )
  22. You all have the best tutorials. I learn new things each time I read one.
    Thanks,

    ( Reply )
  23. PG

    Andrew Johnston August 4th

    Thanks for the CI series. I recently downloaded the framework and these are the perfect tuts for me to get a head-start in learning how to develop using CI.

    Keep up the good work!

    ( Reply )
  24. PG

    Keith Jackson August 4th

    The requirement for the /r/n is in the RFC (not sure which one). Since you’re on a MAC, /r/n would not be sent automatically.

    ( Reply )
  25. PG

    leo rapirap August 4th

    i just watched the video, i’ve never thought sending emails using codeigniter framework is so much fun and easy.

    i’ve been struggling sending emails using plain php, even drove to drinking
    and pulling out my hair. pffft!

    thank you so much jeff for posting this kind of tutorials.

    keep it up jeff!

    ( Reply )
  26. PG

    damon sharp August 4th

    I agree with the comments pertaining to logical progression. Although I can follow just fine, it would be great to walk through building a site from scratch in more of a logical manner. Something more along the lines of the Wordpress for Designers series (minus the Photoshop portion). Thanks, and keep up the great work!

    ( Reply )
  27. PG

    Piero August 4th

    Why u dont simply use base_url() instead $_SERVER['DOCUMENT_ROOT'] ?

    ( Reply )
    1. PG

      Jeffrey Way August 4th

      They’re different paths.

      ( Reply )
  28. PG

    bballbackus August 4th

    Jeffery I just wanted to say I love these tutorials (codeigniter tuts, diving into php tuts, jQuery for absolute beginners) I watch them all religiously and I have to say you are a great teacher!

    ( Reply )
    1. PG

      Jeffrey Way August 4th

      Thank you. Thank you. :)

      ( Reply )
  29. PG

    Sumesh August 4th

    Finally, day 3 is in!

    I might get thumbs down from others, but I really think you should put the remaining videos of CI from scratch on PLUS. That way, we’ll be assured that you won’t quit the series mid-way, it would be a shame to do so.

    ( Reply )
  30. PG

    shiaw uen, tan August 4th

    Good job Jeff!

    ( Reply )
  31. PG

    arnold August 4th

    you are so awesome Jeffrey…I really learn a lot with your tutorials, thanks

    ( Reply )
  32. PG

    ibs August 4th

    you are proving how worth you are as nettus editor. what a choice collis and the gang made. keep up the good work jeff as i am learning a lot from you.

    ( Reply )
  33. PG

    Matt August 4th

    Yes Yes!!!! Absolutely fantastic! Love your stuff, Jeff. I have been waiting on the edge of my seat for the last four days in anticipation. Keep it up!

    ( Reply )
  34. PG

    Kyle August 4th

    Loud noises! Keep em coming please!

    ( Reply )
  35. PG

    KevinBrown August 4th

    Great! Thanks a lot!

    ( Reply )
  36. PG

    David Rojas August 4th

    These tuts are great, don’t stop them! Just two suggestions:
    Make them a bit more advanced, I think most of us already get the grips of basic stuff with CI, and please make them iPod/iPhone compatible (just like the rest of nettuts screencast).

    ( Reply )
    1. PG

      Jon Piehl August 5th

      The NetTuts screencasts can be downloaded as Podcasts for iPod/iPhone compatibility through iTunes. Just search “NetTuts”.

      ( Reply )
      1. PG

        David Rojas August 6th

        I know, I’ve been getting the screencasts that way since the beginning, but the CI series secreencasts aren’t working on iPhone/iPod, because the resolution is too high (iPod/iPhone accepts a max of 640×480 I think).

  37. PG

    jakot August 4th

    Hi Jeff and everybody here,

    Right now Im trying to make a decision between choose Codeigniter or Zend Framework. Do you have any comment about it?

    Thanks in advance,

    ( Reply )
  38. PG

    Trae Regan August 4th

    …being LOUD per your request in the screen-cast. Please do continue the CI tuts series. Great work, thanks!

    ( Reply )
  39. PG

    Dave August 4th

    Nice work on the CI tut. I agree with one of the comments above, put the rest of the series on PLUS

    ( Reply )
  40. PG

    Martin Førre August 5th

    “Look to check to see” :P

    The “set_newline” method allows you to set what you want to use to make a new line in the email message, by default it’s “\n”, but to get it to comply with RFC 822 you have to use “\r\n”.

    ( Reply )
  41. PG

    Ejaz August 5th

    Great easy to understand tutorial. Can’t wait for day 4.

    ( Reply )
  42. PG

    Erwan August 5th

    Excellent as usual.

    ( Reply )
  43. PG

    Shaun C. August 5th

    Woooooo! Yaaaaah!! ((Bangs pots and pans together)

    Keep this series going! Loving it, and makes me want to continue to come back for more!!

    :)

    ( Reply )
  44. PG

    bvde August 5th

    I have a notice from PHP
    A PHP Error was encountered
    Severity: Notice
    Message: Undefined variable: config
    Filename: controllers/email.php
    Line Number: 10 ($this->load->library(’email’, $config);)
    It works the mail is sent. But i don’t find to get rid of this message.

    Your tutorials are great and your accent is very easy to understand for a french speaking.

    ( Reply )
    1. PG

      Neil Bradley August 8th

      @bvde,

      You will need to take out the $config.

      Replace this line;
      $this->load->library(’email, $config’);

      with the following;
      $this->load->library(’email’);

      ( Reply )
      1. PG

        Chris September 22nd

        That was a big help! thanks! I thought I had to do this but I wasn’t entirely sure.

      2. PG

        Chris September 22nd

        I notice that in Jeff’s code he doesn’t take out the $config.

  45. PG

    Mike August 5th

    Loving this series, although very familiar to CI never hurts to check out the basics again.

    Keep it up!

    ( Reply )
  46. PG

    Paul August 5th

    All his tutorial are very good.

    Great and easy follow tutorial for CI-beginners.

    Thanks a lot!

    ( Reply )
  47. PG

    Kenshin August 5th

    Great turorial, thank’s!

    I am really interested to see JQuery+CI to manage cool table effects.

    Keep up the good work!

    Kenshin

    ( Reply )
  48. PG

    John Rawsterne August 5th

    I’ve watched all 3 tuts and learned new stuff from each of them. So thanks :D

    From a personal point of view, I’d love to see a tut about user authentication with CI.

    Like how do we authenticate a user and then set privileges for that user.

    Keep em coming!

    ( Reply )
  49. PG

    Gregg August 5th

    Great tutorials, don’t stop them. I am learning CI and php for that matter and this has been great!!!!!

    ( Reply )
  50. PG

    jeanv August 5th

    Hi, great stuff thanks for the video. Well sending email i easy with CI but it’s always good to have a look back to the basics!

    Maybe you could have talked about the $this->email->clear(TRUE); for sendinf multiples emails.

    A last thing, it would be maybe a good idea to post a link to each user guide page used in the tuto, for example:

    email class: http://codeigniter.com/user_guide/libraries/email.html

    … and is your software used for coding is avalaible on Windows ? (i’m using eclipse but your program seems to be well done for php object dev)

    ( Reply )
    1. PG

      Tomos August 5th

      Great tutorial.

      The software he uses (I think) is textmate for Mac (http://macromates.com/).

      ( Reply )
    2. PG

      Riad August 31st

      Maybe you should try e-texteditor ;)
      http://www.e-texteditor.com/

      ( Reply )
  51. PG

    jeanv August 5th

    ok thanks Tomos

    ( Reply )
  52. PG

    Dion Jensen August 5th

    Great screencasts, being new to frameworks this is really helping me alot in understanding it :)

    ( Reply )
  53. PG

    kamal August 5th

    Hi,
    thank you for that tutorial, but i search a tutorial about MVC Symfony.

    plz if you have a idee, can you do it?

    thanks.

    ( Reply )
  54. PG

    Mathew August 5th

    Jeff : You don’t need to write a constructor if all it does is call the parent, that’s bad practice. Another thing you did which didn’t make such sense was to put the document root variable into the CodeIgniter configuration file. You’re basically abstracting something which is incredibly easy to remember by default. What are you gaining from this?

    It was a good tutorial, but nothing you couldn’t do if you just read the manual.

    ( Reply )
    1. PG

      Jeffrey Way August 5th

      You’re right about the constructor function; however, we’ll be adding to that method in future tutorials.

      In reference to the new config item, I did that to demonstrate how you could add new keys to the config folder easily.

      ( Reply )
  55. PG

    JJ August 5th

    I wouldn’t mind seeing how CI could handle a basic membership site or user authorization.

    Also, is it necessary to hide or take the configuration folders outside the public_html folder for security? CI security would be nice tut too!

    Videos are great keep it going!

    Many thank yous!

    ( Reply )
  56. PG

    kman563 August 5th

    Have loved all your tuts. Thanks a ton. Just started working with CI because of these vids.

    ( Reply )
  57. PG

    Justin August 5th

    Nice work Jeff! I’m enjoying this series a lot!

    ( Reply )
  58. PG

    Jermaine Hercules August 5th

    I got this error, can someone please help I stuck

    Message: mail() [function.mail]: Failed to connect to mailserver at “localhost” port 25, verify your “SMTP” and “smtp_port” setting in php.ini or use ini_set()

    Filename: libraries/Email.php
    line number: 1519

    ( Reply )
    1. PG

      Jon Piehl August 5th

      You might not have set up the email configuration. Your app is trying to send an email through your localhost, but the localhost on your machine can’t send emails. You have to send an email through an email server (ie Gmail). Make sure you follow Jeff’s example on how to configure the email library to work with external email servers.

      ( Reply )
      1. PG

        Jermaine Hercules August 5th

        I did but now Message: fsockopen() is not enable i look in php.ini but cant find it anywhere. also im using a PC if that makes any difference

      2. PG

        Mibu_Kyoshiro August 10th

        Someone plzzz help….
        I’m trying to recreate the tut using Wamp Server 2.0
        I’ve enabled OpenSSL.
        I still can send mail from my local codeigniter installation. I’ve tried everything from having the config settings in the controller to moving them into a email.php file :(

        I STILL get the following error message:A PHP Error was encountered

        Severity: Warning

        Message: mail() [function.mail]: Failed to connect to mailserver at “ssl://smtp.googlemail.com” port 465, verify your “SMTP” and “smtp_port” setting in php.ini or use ini_set()

        Filename: libraries/Email.php

        Line Number: 1519

        p.s Where is “Jeff’s example on how to configure the email library to work with external email servers.”?

  59. PG

    Lorenzo August 5th

    I love this kind of series tutorials! Good Work Jeff =)

    ( Reply )
  60. PG

    Joakim August 5th

    Love this serie, great tutorials! I really learn alot from them, thanks alot! =D

    ( Reply )
  61. PG

    Dan August 5th

    Great tutorial jeff!!

    ( Reply )
  62. PG

    Mark Jones August 5th

    Having some problems with Authentication, has someone changed the password or something? When I try and use my gmail account the page doesn’t load, simply gets stuck loading.

    ( Reply )
    1. PG

      Jeffrey Way August 5th

      Yeah – I think somebody did. Just use your own credentials. :)

      ( Reply )
  63. PG

    Paul du Long August 5th

    Hello Jeff,

    Thanks for this tutorial! Just in time because I just needed it for a big new project.bI might have an improvement for you.

    Because this new project I’m working on is queit big i have a lot of global data, such as email-address, sitename, siteUrl etc. What i did was; I created a new model within this model I defined those constants and then autoloaded this file via the autoload file.

    I don’t know if this is the best way to do it but it works for me.
    Let me know if this method works for you and I can’t wait for the next tutorial of CI.

    Regards,
    Paul du Long

    ( Reply )
  64. PG

    Dean August 5th

    Thanks for this brill CI series!!
    When will this episode be available on iTunes?

    ( Reply )
  65. PG

    Dion Jensen August 5th

    Would it be possible for you to include the screencasts in the source file? I ask mainly so i can work offline while still watching them after i’ve downloaded them.

    ( Reply )
    1. PG

      Jason August 10th

      You can get them from itunes. Search nettuts. There’s a podcast.

      ( Reply )
  66. PG

    Chris August 5th

    Hey Jeff,

    You are making my lunches on Tuesday or Wednesday great with these CI Tutorials. Keep it up!!!

    Anyway you can go into some detail about HTML emails next week?

    ( Reply )
    1. PG

      Jeffrey Way August 5th

      Yes sir! What were we having for lunch?

      ( Reply )
  67. PG

    marc-andre menard August 5th

    Amazing…. I was in the decision to go native php for a site or with a framework, your guidance is just taking me to take the step i need to go with code igniter…

    I will need some tutorial on database, get data, and show it. It will be cool to see that soon.

    And the best of the best, a ci tuts to get data in a database and modify it and delete it… CRUD in fact

    ( Reply )
    1. PG

      Jeffrey Way August 8th

      Okay – I’ll do a CRUD tut in the next two weeks or so.

      ( Reply )
  68. PG

    Joe August 5th

    Definitely looking forward to more of these. I just watched all 3 and CI seems fun. Keep it up.

    ( Reply )
  69. PG

    digitalbart August 5th

    Good job Jeff! Keep these coming!

    ( Reply )
  70. PG

    Paul du Long August 6th

    Plzz help …. i keep getting this error:

    A PHP Error was encountered

    Severity: Warning

    Message: fsockopen() [function.fsockopen]: unable to connect to ssl://smtp.googlemail.com:465 (Unable to find the socket transport “ssl” – did you forget to enable it when you configured PHP?)

    Filename: libraries/Email.php

    Line Number: 1646

    PHPINFO SAYS OPENSSL IS ENABLED :S:S

    ( Reply )
    1. PG

      Jermaine Hercules August 6th

      I have this same problem, how I fixed was simply enabling php_openssl from you php.ini just php_opensll remove the ; good luck

      ( Reply )
      1. PG

        Jeffrey Way August 7th

        Yes – I should have mentioned that openssl needs to be enabled on some computers.

      2. PG

        Dave Redfern September 13th

        Hello Jermaine,

        Could you explain exactly what you did to enable php_openssl? I’m running mamp but really struggling where to look and what to do.

        Thanks

        Dave.

    2. PG

      paul August 9th

      I have the same problem, I enabled openssl, but problem remains, even after I restarted apache

      ( Reply )
  71. PG

    Ben August 6th

    These are great video’s please keep them coming!!

    ( Reply )
  72. PG

    Paul Demers August 6th

    I am really enjoying these tutorials. I have been wanting to really learn CodeIgniter for a while now and just haven’t been able to wrap my head around it. This set of tutorials is really helping break it down. Great work as always!

    ( Reply )
  73. PG

    SNaRe August 6th

    When will new tutorial be released ? And what will be the content

    ( Reply )
    1. PG

      Jeffrey Way August 7th

      I’m shooting for every Monday/Tuesday.

      ( Reply )
  74. PG

    Zac August 6th

    This is so awesome! Please, more more!

    ( Reply )
  75. PG

    fahri August 7th

    I search all over Google to find best tips and tricks about CodeIgniter, and i think this is one of them. But you know i need more and more about CodeIgniter.

    Anyone can tell me how to parse JSon with CI?

    ( Reply )
  76. PG

    Mike August 8th

    Hi you make great job . Thanks

    ( Reply )
  77. PG

    mehdi August 9th

    I’ll CI , specially in your tutorials . keep up the good work . can i share the sample application I have been write for you may be help for other tutorial . :)
    sorry about misspell or grammar .

    ( Reply )
  78. PG

    paul August 9th

    I’m falling in love with codeigniter!
    thank you so much for these tutorials.
    It really takes the pain out of coding php.

    ( Reply )
  79. PG

    Cuijiudai August 10th

    I have just begin to learn some php frames,when I begin to find some tutoriols
    I found it.Then I discide to learn CI .I think that php should be easy,fast and safe,why must we talk so much of OOP,just go itslef way ,why have to learn about java or ruby on rail.
    last thing ,why “beginhtml” does not work in my e ,I see you can do it,and save a lot of time.thinks

    ( Reply )
  80. PG

    Jason August 10th

    Will there be a tut in this series on the CI form validation class? That’s one aspect of CI that I’m interested in.

    ( Reply )
  81. PG

    GaVrA August 11th

    Thanks jeff! Really great series, keep ‘em comming! ;)

    ( Reply )
  82. PG

    wtp August 11th

    I’d like to see advanced forms, like nested forms, and how you mangage many-to-many relationships, that sort of stuff that I never mangaged to do with ruby on rails.

    ( Reply )
  83. PG

    timo.huber August 12th

    thanks so much.
    i love these tuts :) ))

    ( Reply )
  84. PG

    Chris August 12th

    Hi Jeff,

    Just got through days 1 to 3 of the CI tutorials. I’m excited that you’re taking the time to cover this framework.

    I look forward to the next tutorial, keep at it.

    Thanks,

    -
    Chris.

    ( Reply )
  85. PG

    rootkowski August 12th

    Great tutorial as always J!

    Just a question: is it only me getting the same email twice every time I refresh the page? I’m testing the code on a local test server (xampp).

    ( Reply )
  86. PG

    Mibu_Kyoshiro August 12th

    Someone plzzz help….
    I’m trying to recreate the tut using Wamp Server 2.0
    I’ve enabled OpenSSL.
    I still can send mail from my local codeigniter installation. I’ve tried everything from having the config settings in the controller to moving them into a email.php file :(

    I STILL get the following error message:A PHP Error was encountered

    Severity: Warning

    Message: mail() [function.mail]: Failed to connect to mailserver at “ssl://smtp.googlemail.com” port 465, verify your “SMTP” and “smtp_port” setting in php.ini or use ini_set()

    Filename: libraries/Email.php

    Line Number: 1519

    p.s Where is “Jeff’s example on how to configure the email library to work with external email servers.”?
    Also, sorry for the double post! I’m not getting any responses on my original post :(

    ( Reply )
    1. PG

      Jared September 11th

      OK. I finally figured this out. Don’t know if this will help anyone, but I changed the wrong php.ini file. If you run the phpinfo command, toward the top, it will have a section called “Loaded Configuration File”. My location was at C:\xampp\apache\bin\php.ini, but I initially changed C:\xampp\php\php.ini with nothing working. Just thought I would pass it along.

      ( Reply )
  87. PG

    Thomas Keller August 17th

    I seem to have similar errors than the previous posters – when I use port 465, nothing happens (the page just loads and loads and loads…); using port 995 (which I found on some other internet resources to be the SSL port for gmail), I get

    Message: fwrite() [function.fwrite]: SSL operation failed with code 1. OpenSSL Error messages: error:140D00CF:SSL routines:SSL_write:protocol is shutdown
    Filename: libraries/Email.php
    Line Number: 1789

    Using port 586, I get

    Message: fsockopen() [function.fsockopen]: SSL operation failed with code 1. OpenSSL Error messages: error:140770FC:SSL routines:SSL23_GET_SERVER_HELLO:unknown protocol
    Filename: libraries/Email.php
    Line Number: 1646

    I am really confused now… Jeff, would be great to help out here :)

    ( Reply )
    1. PG

      Kenny Vaneetvelde September 19th

      I get the same error, jeff help us out please!

      ( Reply )
  88. PG

    Magnus von Bromsen August 17th

    Hello Jeff

    Please, you must continue with the screencats’s.

    I spent one week comparing and trying a couple of Frameworks. And decided to go with Codeigniter, mainly because of these fantastic screencast’s (and other good tutorials).

    Don’t you dare to stop now :)

    – magnus

    ( Reply )
    1. PG

      Jeffrey Way August 18th

      Thanks! :) No way. New screencast sometime this week. (It’s been rescheduled a bit, due to our birthday celebration.

      ( Reply )
  89. PG

    Richard S. August 19th

    Great series. Looking forward to more of them.

    And one more question. I really loved the colors you use for marking PHP code. Can you somehow write the colors down or share them in other way? :) Would be great.

    ( Reply )
  90. PG

    Steve K August 19th

    Hi, Jeff!
    Not sure if you’re still reading these, but I just have to say thank you! These tutorials are some of the most clearly communicated I’ve ever had the pleasure to watch. Thank you again, sir! How’s Australia treating you?

    PS: If I have a request or an idea for a tutorial for nettuts, what’s the best way to offer my suggestion?

    Thanks again!

    ( Reply )
    1. PG

      Jeffrey Way August 19th

      Thanks, Steve!

      ( Reply )
  91. PG

    James August 28th

    I’m enjoying this series a lot, keep them coming!

    ( Reply )
  92. PG

    Alvin Crespo August 30th

    Awesome tutorial. Ive been doing emails in php for a while and Im on day 4 right now after a two day marathon of this series and I am so impressed with what Code Igniter has to offer. I can most certainly see the power this framework has to offer and I’m impressed at your teaching style, its both professional and easy to understand. Keep them coming, I would love to see more. A few things I would like to see are: Regular Expressions for creating a Blog site like Drupal parsing content to automatically create p tags and break tags in a form body text area submission, database logic for joining tables in a code igniter based site, News aggregation using xml based feeds.

    Again, great tutorial and now im onto week 5. Thanks!

    ( Reply )
  93. PG

    emcgfx August 30th

    Hey Jeff, in this tutorial the only thing I needed to add to my /controllers/email.php file is $config = $this->config->item(’config’); otherwise I got an error Message: Undefined variable: config

    The rest worked perfectly. Thank you again for this good video. Good Job Jeff.

    ( Reply )
    1. PG

      ci newbie September 25th

      Can you tell me why? I got the same error when using the configuration file email.php in /config.

      ( Reply )
  94. PG

    Nick August 31st

    Wonderful screencasts. Keep ‘em coming. I’m even considering a net.tuts+ account.

    ( Reply )
  95. PG

    Paolo Carpo September 2nd

    Don’t konw if this can help but, anyway…

    If you test all these thing on HostMonster, you should use ’sendmail’ instead of ’smtp’ in protocol, ‘cos smtp isn’t support on HM (this drives me crazy for about an hour :-( )

    Thanks Jeffrey, you did a great job!!

    ( Reply )
  96. PG

    Kujo September 3rd

    Same problem of Paul :(

    Message: fsockopen() [function.fsockopen]: unable to connect to ssl://smtp.google.com:465

    I’ve already enabled php_openssl.dll

    ( Reply )
    1. PG

      Paolo Carpo September 4th

      try:

      ’smtp_host’ => ’ssl://smtp.googlemail.com’,
      ’smtp_port’ => 995,

      ( Reply )
      1. PG

        Becky September 8th

        I have this problem too, when I tried 995 it gave another error:

        A PHP Error was encountered

        Severity: Warning

        Message: fwrite() [function.fwrite]: SSL operation failed with code 1. OpenSSL Error messages: error:140D00CF:SSL routines:func(208):reason(207)

        Filename: libraries/Email.php

        Line Number: 1789

    2. PG

      Vincent C October 9th

      Did you enable the it in the right file?
      I have had this too and searched for hours for a fix but in the end I edited the wrong php.ini file.

      I use Xampp, and edited xampp/php/php.ini but you should edit xampp/apache/bin/php.ini

      Hope this helps!

      ( Reply )
  97. PG

    Moyo September 11th

    If you stop These wonderfull tutorials, I will come there and kill you. (just kidding)

    But seriously though, Please go all the way.

    I am forever grateful to your hard work and for sharing.

    You will be referenced in all my future works. :)

    ( Reply )
    1. PG

      Jeffrey Way September 11th

      Thanks!

      ( Reply )
  98. PG

    Martin September 14th

    Wasn’t able to get this one working, hope day 4 is better.

    Mac OS X 10.4.11
    MAMP (Apache 2.0.59, PHP 5.2.6)
    openssl extension installed & enabled
    sendmail working with normal PHP

    Tried ports 465, 586, 995. I get the same errors as Thomas Keller above.

    At least I’m learning some CI, so thanks.

    ( Reply )
  99. PG

    AzeriFire September 14th

    Hi. I learn English language, proffesional coding style and CI in one tutorial :) Dont stop it plz , just Music :) Thanks.

    ( Reply )
  100. PG

    RC September 15th

    Holy Schniekes!

    This tutorial is insane great! It truly saved my arse! Thank you so much Jeffrey! I’m so excited about Codeigniter since I’m fairly new to PHP (i’ve only been coding with it for about a year and I was already getting sick of spaghetti code.) It is only until recently that I have been learning about the wonders of frameworks and I love the simplicity of this one but even more, I love its documentation!

    ( Reply )
  101. PG

    Edgar September 17th

    Awesome tutorials dude

    ( Reply )
  102. PG

    Kenny Vaneetvelde September 19th

    okay, to everyone who is having issues sending the email (like those ssl errors, or that it keeps loading on port 465) i have found the answer!

    i am pretty sure, in your code, you have this

    $this->email->set_newline(’\r\n’);

    ‘ (single quote) should be ” (double quote, AKA magic quotes) and then it will work, strange, and sad, but true.

    so change it to

    $this->email->set_newline(”\r\n”);

    ( Reply )
    1. PG

      Dmitri November 9th

      Thank you. It worked for me :)

      ( Reply )
  103. PG

    yura September 21st

    instead
    $this->email->set_newline(”\r\n”)
    you can use
    $config['newline'] = “\r\n” (only in double quotes)
    in your email.php config file

    and thanks for screencasts!

    ( Reply )
  104. PG

    sunil September 21st

    This is great and easer than cAkE

    ( Reply )
  105. PG

    Dionis September 25th

    Great work Jeff! Keep on doing this!

    ( Reply )
  106. PG

    Brennan Novak September 27th

    I loving the tutorials the most! Awesome job! Just purchased a Net-Tuts+ :)

    However, I keep getting these nasty errors

    A PHP Error was encountered
    Severity: Warning
    Message: fsockopen() [function.fsockopen]: unable to connect to smtp.googlemail.com:25
    Filename: libraries/Email.php
    Line Number: 1646

    First I realized that for some reason when I run it from my localhost via MAMP no email is ever sent even it gives the confirmation email… I’m about to update my MAMP version.

    So then I uploaded a copy to my server and still got all the errors. I tried all of the suggestions above and the only solution that makes them go away and allow an email to be sent is remove the $config variable from this line:

    $this->load->library(’email’, $config);

    so it looks like this

    $this->load->library(’email’);

    and of course in which case I need to keep the config settings in that file… any thoughts or insights and this is very peculiar?

    ( Reply )
    1. PG

      Brennan Novak September 27th

      Ahhhhh figured it out. I’m a total tool. Misspelled “smtp_port” as “smtp_post”

      ( Reply )
  107. PG

    Marshall September 29th

    Hey Jeff, I just wanted to let you know first of all how awesome this framework is. I’ve never worked with one before, and so far it’s absolutely amazing. Second, your videos have been immensely helpful, please keep them up!

    ( Reply )
  108. PG

    Kiruban PREMKUMAR October 4th

    Hello Jeff,

    Firstly, I want to thank you!! :) You are doing a great Job!! Keep it Up!!

    I wonder if you could deal with the creation of library, helpers, and the way we could integrate a live file uploading progress bar into codeigniter?

    For example a screencast about the integration of uberupload or fancyupload…

    It will be very nice!! :)

    ( Reply )
  109. PG

    Allan October 8th

    Yes I totally agree the nettuts is one of the best. They are being unselfish and shares a lot of things.

    ( Reply )
  110. PG

    Ken October 14th

    Be sure that your server firewall doesn’t block those ports or you will get nothing but errors. That’s what you get for using cheap hosting.

    ( Reply )
    1. PG

      Ken October 14th

      Nevermind! I was on Host Monster and a previous post mentioned to switch the protocol to sendmail instead of smtp and it worked all of the sudden. Yay for forums.

      ( Reply )
      1. PG

        Sean Davies November 11th

        Same here!

  111. PG

    Bart October 26th

    ERROR: My browser hangs on the send() function when trying to send email to a gmail account. Here’s my code:

    $config = Array(
    ‘protocol’ => ’smtp’,
    ’smtp_host’ => ’ssl://smtp.googlemail.com’,
    ’smtp_port’ => 465,
    ’smtp_user’ => ‘accountname@gmail.com’,
    ’smtp_pass’ => ‘accountpass’
    );

    $this->load->library(’email’, $config);
    $this->email->set_newline(’\r\n’);

    $this->email->from(’accountname@gmail.com’, ‘Bart Schroder’);
    $this->email->to(’accountname@gmail.com’);
    $this->email->subject(’This is an email test’);
    $this->email->message(’It works’);

    if($this->email->send())
    {
    echo ‘Your email was sent. Great job!’;
    }
    else
    {
    show_error($this->email->print_debugger());
    }

    Can you help?

    ( Reply )
  112. PG

    Balazs Csaba October 28th

    Wooow…Thanx very much, great tutorials, keep on going!
    Really apreciate what u’re doing…

    Thx again ;)

    ( Reply )
  113. PG

    kdog October 31st

    Great tutorial! Thanks.

    ( Reply )
  114. PG

    Seday Matzumiya November 11th

    Thanks man… great tutorials, i really like your way! Do you use Texter or something like that @ Mac?

    Thank you.

    ( Reply )
  115. PG

    dan November 18th

    wont work for php 5.3

    Deprecated: Assigning the return value of new by reference is deprecated in C:\wamp\www\ci_day3\system\codeigniter\Common.php on line 130

    Deprecated: Assigning the return value of new by reference is deprecated in C:\wamp\www\ci_day3\system\codeigniter\Common.php on line 136

    source file needs to be updated

    ( Reply )
  1. Arrow
    Gravatar

    Your Name
    November 18th