I want to send mail using codeigniter. I am using codeigniter as mailer. i have written a controller and upload it on net . when i call the controller. This shows errors.I am writing my controller like
<?php
class Testmail extends CI_Controller {
public $data = array();
public function __construct()
{
parent::__construct();
$this->load->helper('url_helper');
$this->load->helper(array('form', 'url'));
$this->load->library('email');
$this->load->helper('url');
}
public function mailsend()
{
$config['protocol'] = 'sendmail';
$config['mailpath'] = '/usr/sbin/sendmail';
$config['charset'] = 'iso-8859-1';
$config['wordwrap'] = TRUE;
$this->email->initialize($config);
$this->email->from('kunal.saxena.kunal@gmail.com', 'Your Name');
$this->email->to('kunal.saxena.kunal@gmail.com');
$this->email->subject('Email Test');
$this->email->message('Testing the email class.');
$this->email->send();
echo $this->email->print_debugger();
}
}
But it is not working and i got the error like
Exit status code: 127
Unable to open a socket to Sendmail. Please check settings.
Unable to send email using PHP Sendmail. Your server might not be configured to send mail using this method.
User-Agent: CodeIgniter
Date: Mon, 28 May 2012 10:51:18 +0000
From: "Your Name"
Return-Path:
To: kunal.saxena.kunal@gmail.com
Subject: =?iso-8859-1?Q?Email_Test?=
Reply-To: "kunal.saxena.kunal@gmail.com"
X-Sender: kunal.saxena.kunal@gmail.com
X-Mailer: CodeIgniter
X-Priority: 3 (Normal)
Message-ID: <4fc358a653ad4@gmail.com>
Mime-Version: 1.0
Content-Type: text/plain; charset=iso-8859-1
Content-Transfer-Encoding: 8bit
Testing the email class.
How to remove this error..?
Make sure your server has sendmail and it is correctly set up, In case you don’t have it and can’t install it you can use googles SMTP server to send emails, this is what I do on localhost. You can find and example of how to do it here
PS. Controller looks fine