Categories
PHP

PHP Email

<?php

class Email extends Controller {

    function Email()

    {

        parent::Controller();  

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

    }

    function index()

    {

        $config[‘protocol’]    = ‘smtp’;

        $config[‘smtp_host’]    = ‘ssl://smtp.gmail.com’;

        $config[‘smtp_port’]    = ‘465’;

        $config[‘smtp_timeout’] = ‘7’;

        $config[‘smtp_user’]    = ‘[email protected]’;

        $config[‘smtp_pass’]    = ‘*******’;

        $config[‘charset’]    = ‘utf-8’;

        $config[‘newline’]    = “\r\n”;

        $config[‘mailtype’] = ‘text’; // or html

        $config[‘validation’] = TRUE; // bool whether to validate email or not     

        $this->email->initialize($config);

        $this->email->from(‘[email protected]’, ‘myname’);

        $this->email->to(‘[email protected]’);

        $this->email->subject(‘Email Test’);

        $this->email->message(‘Testing the email class.’); 

        $this->email->send();

        echo $this->email->print_debugger();

        $this->load->view(’email_view’);

    }

}