Send Email with Attachment using SMTP – PHP Codeigniter

In this post, you will learn how to send emails in PHP using SMTP. Like PHPMailer, there are a few more good email sending libraries in PHP

Add ‘email‘ library


$autoload[‘libraries’] = array(’email’);

Controller Page Code

public function sendEmailAmd()

    $config = Array('protocol' => 'sendmail',
            'smtp_host' => '',
            'smtp_port' => 25,
            'smtp_user' => '',
            'smtp_pass' => 'infoXXXXXX',
            'smtp_timeout' => '4',
            'mailtype' => 'html',
            'charset' => 'iso-8859-1');

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


            $message='Abdul Mohammad Message';



            $this->email->from('senderemail', 'Message');

            if($this->email->send()) {
            echo 'Mail Sent';

            } else {
            echo 'NOT Sent';

Leave a Reply

Your email address will not be published. Required fields are marked *