• Newsticker

    Kamis, 17 Mei 2018

    PHP Mailer and Codeigniter 3

    1. installing PHP Mailer

    Download the latest PHPMailer Build from Github. You can find the project here
    Click now on "clone or download" and download it as zip - as in the image below is shown. PHP Mailer Download as ZIP
    The folder in the zip is called PHPMailer-master. Unzip this in your application/third_party/ folder and rename the folder to phpmailer. You should see something like this enter image description here

    2. PHP Mailer Library

    Imho its best to create a library which handles your PHPMailer Object (PHPMailer_Library.php) This library could look like
    class PHPMailer_Library
    {
        public function __construct()
        {
            log_message('Debug', 'PHPMailer class is loaded.');
        }
    
        public function load()
        {
            require_once(APPPATH."third_party/phpmailer/PHPMailerAutoload.php");
            $objMail = new PHPMailer;
            return $objMail;
        }
    }

    3. Using this library in one of your controllers, models etc.

    class Welcome extends CI_Controller {
    
    
        public function index()
        {
            $this->load->library("phpmailer_library");
            $objMail = $this->phpmailer_library->load();
        }
    }
    i think this should pretty much do the job. If you've any troubles, don't hesitate to ask ;)


    Sumber: https://stackoverflow.com/questions/44843305/how-to-integrate-phpmailer-with-codeigniter-3

    Tidak ada komentar:

    Posting Komentar

    Agama

    Agama

    Agama

    Agama

    Agama

    Agama