Mackintoast
Mackintoast

Reputation: 1437

Sending an email in codeigniter

To send an email I have set the config as follows

$config['protocol'] = 'smtp';
$config['charset'] = 'iso-8859-1';
$config['wordwrap'] = TRUE;

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

$this->email->send();

My outlook email account smtp is set up as

mail.mycompany.com

I have got error for sending an email from this account to any other accounts. I forget the error message and I can not replicate it right now on this computer, but look at those config's, do you think it is correct ? (before call function send to send an email I also included the call to its initializer or to load its library for use in the controller contructor already).

Upvotes: 0

Views: 1161

Answers (1)

groovekiller
groovekiller

Reputation: 1122

OK, try to use protocol sendmail

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

$this->email->initialize($config);

If You're using smtp protocol You need to define whats Your smtp params:

$config['smtp_host']     
$config['smtp_user']    
$config['smtp_pass']     

Then

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

$this->email->send();

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

Upvotes: 1

Related Questions