Codeigniter provides many built in helpers and libraries which help us to perform lot of functionality for developing projects. Here a simple email library make us able to send email using our Gmail account living in CI environment.
<?
class Send_Email extends Controller
{
function Send_Email()
{
parent::Controller();
}
function index()
{
$config = Array(
'protocol' => 'smtp',
'smtp_host' => 'ssl://smtp.googlemail.com',
'smtp_port' => 465,
'smtp_user' => 'email_address@gmail.com', // change it to yours
'smtp_pass' => 'your_password', // change it to yours
'mailtype' => 'html',
'charset' => 'iso-8859-1',
'wordwrap' => TRUE
);
$this->load->library('email', $config);
$this->email->set_newline("\r\n");
$this->email->from('your_email@domain.com'); // change it to yours
$this->email->to('your_email@domain.com'); // change it to yours
$this->email->subject('Email using Gmail.');
$this->email->message('Working fine ! !');
if($this->email->send())
{
echo 'Email sent.';
}
else
{
show_error($this->email->print_debugger());
}
}
}
?>
<?
class Send_Email extends Controller
{
function Send_Email()
{
parent::Controller();
}
function index()
{
$config = Array(
'protocol' => 'smtp',
'smtp_host' => 'ssl://smtp.googlemail.com',
'smtp_port' => 465,
'smtp_user' => 'email_address@gmail.com', // change it to yours
'smtp_pass' => 'your_password', // change it to yours
'mailtype' => 'html',
'charset' => 'iso-8859-1',
'wordwrap' => TRUE
);
$this->load->library('email', $config);
$this->email->set_newline("\r\n");
$this->email->from('your_email@domain.com'); // change it to yours
$this->email->to('your_email@domain.com'); // change it to yours
$this->email->subject('Email using Gmail.');
$this->email->message('Working fine ! !');
if($this->email->send())
{
echo 'Email sent.';
}
else
{
show_error($this->email->print_debugger());
}
}
}
?>
how do u use this script?
ReplyDeletethank you so much for this i was really looking for this but i i want to send an email form my html contact form !! can you give me some idea for this or some coding through which i can send an email. best web design company
ReplyDelete