I'm nidhin
I'm nidhin

Reputation: 2662

Can't send mail in codeigniter

I'm using the following code for sending mail in codeigniter

$this->load->library('email');
$this->email->set_mailtype('html');
$this->email->from('[email protected]', 'Your Name');
$this->email->to('[email protected]'); 

$this->email->subject('Email Test');
$this->email->message('Testing the email class.');  

$this->email->send();

echo $this->email->print_debugger();

Here I'm getting the error as

Unable to send email using PHP mail(). Your server might not be configured to send mail using this method.

But if the mail type is change to text, ie

$this->email->set_mailtype('text');

It works fine.Why is it so ?

Upvotes: 2

Views: 1626

Answers (2)

Hyeonil Choi
Hyeonil Choi

Reputation: 1

Need an email.php file.

$config['protocol'] = 'sendmail';
$config['mailpath'] = '/usr/sbin/sendmail';
$config['charset'] = 'iso-8859-1';
$config['wordwrap'] = TRUE;

reference, this URL: http://www.ciboard.co.kr/user_guide/en/libraries/email.html

Upvotes: 0

Brijesh Tanwar
Brijesh Tanwar

Reputation: 143

$config['charset'] = 'utf-8';
$config['wordwrap'] = TRUE;
$config['mailtype'] = 'html';
$this->email->initialize($config);

Try this.

Upvotes: 1

Related Questions