简体   繁体   中英

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).

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();

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM