CI silently re-runs email->initialise with default variables AFTER the config file has been successfully run through there, which removes all custom settings.
This means in my case that SMTP settings are ignored and the default sendmail system is used, which is wrecking the application.
The fix I used, to demonstrate the issue (not at all acceptable for most cases but it bypasses the errant re-call):
public function initialize($config = array()) {
qlog($config, 'initialize $config');
if ($config['protocol']=='smtp') {
//the usual code is moved to here
}
return $this;
My controller:
$to = 'an@email.com';
$this->load->library('email');
$this->email->from(SITE_EMAIL_ADDRESS, SITE_EMAIL_NAME);
$this->email->to($to);
$this->email->subject("testing email system");
$this->email->message("Hi - we're testing the email connectivity between your server and ours. So if you're seeing this then presumably all went well. Please ignore this message, no action is required on your part.");
$this->email->send();
qlog($this->email->print_debugger());
Without my fix, the debugger reports successful send VIA SENDMAIL.
CI silently re-runs email->initialise with default variables AFTER the config file has been successfully run through there, which removes all custom settings.
This means in my case that SMTP settings are ignored and the default sendmail system is used, which is wrecking the application.
The fix I used, to demonstrate the issue (not at all acceptable for most cases but it bypasses the errant re-call):
My controller:
Without my fix, the debugger reports successful send VIA SENDMAIL.
My config file:
$config['protocol'] = 'smtp'; $config['smtp_host'] = 'mail.domain.co.uk'; $config['smtp_user'] = SITE_EMAIL_ADDRESS; $config['smtp_pass'] = SITE_EMAIL_PASSWORD; $config['newline'] = "\r\n"; $config['crlf'] = "\n"; //long subjects break iso spec without this $config['charset'] = 'utf-8'; $config['wordwrap'] = TRUE;
This works perfectly with my fix, so config values are not at fault.
Updated for formatting and to remove a testing email address.