ci_series_3_001
We show how to send mail in codeigniter in http://learneveryday.net/php/framework/codeigniter/ci_series/sending-email-in-codeigniter/ . Today we will show how to send attachment. We just need to add two line of code to send attachment.
Bellow is the code.
<?php

/**
* SENDS EMAIL WITH GMAIL
*/
class Email extends Controller
{
function __construct()
{
parent::Controller();
}

function index()
{



$this->load->library('email');
$this->email->set_newline("\r\n");

$this->email->from('learneverydaytutorials@gmail.com', 'Arifur Rahman');
$this->email->to('learneverydayTutorials@gmail.com');
$this->email->subject('This is an email test');
$this->email->message('It is working. Great!');


$file = './attachments/Info.txt';


$this->email->attach($file);

if($this->email->send())
{
echo 'Your email was sent, successfully.';
}

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


}
}

?>
文章標籤

mitblog 發表在 痞客邦 留言(0) 人氣(76)