CodeIgniter From Scratch: Day 3
videos

CodeIgniter From Scratch: Day 3. Sending Emails

This entry is part 3 of 17 in the CodeIgniter From Scratch Session
« PreviousNext »

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.

Catch Up

Day 3


Add Comment

Discussion 390 Comments

Comment Page 6 of 6 1 ... 4 5 6
  1. Sat says:

    Awesome Tutorials dude… Thanks a lot… I am learning real codeIgniter from your tutorials.. Plz keep going….

  2. Mr Chub says:

    Great
    But i have a error:
    Call to undefined method CI_Controller::controller() in C:\wamp\www\ci\application\controllers\email.php on line 10
    Here is my code:
    class Email extends Ci_Controller{

    function __construct()
    {
    parent:: controller();
    }
    function index()
    {
    $config = Array(

    ‘protocol’=>’smtp’,
    ‘smtp_host’=>’ssl://smtp.googlemail.com’,
    ‘smtp_port’=>465,
    ‘smtp_user’=>’myemail’,
    ‘smtp_pass’=>’mypass’

    );

    /*forbinder til libary */
    $this->load->libary(‘email’, $config);
    $this->email->set_newline(“\r\n”);

    /*afsenderen*/
    $this->email->from(‘nettutsTutorials@gmail.com’);
    /*modtageren*/
    $this->email->to(‘renefrisker@gmail.com’);
    $this->email->subject(‘Det er en email test’);
    $this->email->messange(‘Det virke sku’);

    if($this->email->send()){
    echo’Din mail bliv sent’;
    }

    else
    {
    show_error($this->email->print_debugger());
    }
    }
    }

    • Peter Häggstrand says:

      @mrChub: Look at the previous comment page, you will find the answer there. It has to do with the version nr of CodeIgniter. This tutorial is based on 1.7, you’re propably using 2.1.

    • Pablo Vera H. says:

      In construct function is: parent::__construct();
      This is for Codeigniter 2.0.

      • Matt says:

        I was getting the same error. I came here after already changing my code to your solution, but I’m now getting a 504 error.

        Gateway Time-out

        The gateway did not receive a timely response from the upstream server or application.

        Any thoughts?

  3. Rene says:

    i have a error:

    Severity: Warning

    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: 1553

    can any one help

  4. Dale says:

    Fantastic series, thanks for making these.

  5. mehmet demir says:

    I am writing exactly the same code but I’m getting error like “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?)” if I get rid of the ssl part it didn’t work again

  6. Roy says:

    Nice Tutorial

  7. Rexx says:

    Man just keep up with good work! Your tutorials really helps, thank you so much!

  8. Edward says:

    Thank you so much for this series!!!! This has been so helpful in learning CodeIgniter!!!!

  9. obaid says:

    you are using live server or local server for email to gmail??????????

  10. obaid says:

    email is sent and no error occur but when i open my gmail account there was no email.
    But the message “your email is sent ,fool” was printed on browser
    please tell me the solution

  11. pinar says:

    awesome tutorials! thanks for taking the time to make them :) keep them coming…

  12. reza says:

    I love these tutorials. Thanks so much for teaching.

  13. Nisho says:

    Thanks for sharing mate, these are just great tutorials!

  14. foo man says:

    This tutorial uses an older version of Code Igniter 1.7? So I made the adjustments for the CI_2.1 using the parent::__construct, but somehow I am still drawing a blank page from my URL http://localhost/shell/index.php/email/index. NO EMAIL WAS SENT FOOL….What should I do to get this to work? I can’t move onto the next tutorial and its frustrating :-/ Thanks in advance!

    ‘smtp’,
    ‘smtp_host’ => ‘ssl://smtp.googlemail.com’,
    ‘smtp_port’ => 465,
    ‘smtp_user’ => ‘user’,
    ‘smtp_pass’ => ‘pass’
    );

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

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

    $this->email->from(‘rezapiri@gmail.com’, ‘Top Dog’);
    $this->email->to(‘rezapiri@gmail.com’);
    $this->email->subject(‘This is an email test’);
    $this->email->message(‘Its working’);

    if($this->email-send())
    {
    echo ‘Your email was sent fool.’;
    }

    else
    {
    show_error($this->email->print_debugger());
    }

    }

    }

  15. foo man says:

    the last post didn’t capture the controller etc…

    ‘smtp’,
    ‘smtp_host’ => ‘ssl://smtp.googlemail.com’,
    ‘smtp_port’ => 465,
    ‘smtp_user’ => ‘user’,
    ‘smtp_pass’ => ‘pass’
    );

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

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

    $this->email->from(‘rezapiri@gmail.com’, ‘Top Dog’);
    $this->email->to(‘rezapiri@gmail.com’);
    $this->email->subject(‘This is an email test’);
    $this->email->message(‘Its working’);

    if($this->email-send())
    {
    echo ‘Your email was sent fool.’;
    }

    else
    {
    show_error($this->email->print_debugger());
    }

    }

    }

  16. Jaiveek says:

    Ur videos r really very much helpful….thnks.. :)

  17. alex says:

    Thanks for all you did. It’s very very good stuff. These videos can teach me a lot!!!

Comment Page 6 of 6 1 ... 4 5 6

Add a Comment

To add a code snippet to your comment, please wrap your code like so: <pre name="code" class="html">YOUR CODE</pre>. You can replace the class name with "js," "css," "sql," or "php." If there are any "<" or ">" within your code, please search and replace them with: &lt; and &gt; respectively.