我可以使用以下代码在本地服务器中发送电子邮件,
$config['protocol'] = 'smtp';
$config['charset'] = 'UTF-8';
$config['mailtype'] = "html";
$config['wordwrap'] = TRUE;
$config['smtp_host'] = $this->config->item('smtp_host'); // smtp.critsend.com
$config['smtp_user'] = $this->config->item('smtp_user');
$config['smtp_pass'] = $this->config->item('smtp_pass');
$config['smtp_port'] = $this->config->item('smtp_port'); // i'm tried 587 and 25
$this->load->library('email');
$this->email->initialize($config);
$this->email->from('test@test.com', 'test');
$this->email->reply_to('test@test.com', 'test');
$this->email->to($user['email']);
$this->email->subject($subject);
$this->email->message($html);
$this->email->set_newline("\r\n");
$this->email->send();
但它不适用于真实服务器。我收到这个错误,
消息:fsockopen() [function.fsockopen]:无法连接到 smtp.critsend.com:25(连接超时)
文件名:库/Email.php
行号:1689
消息:fwrite():提供的参数不是有效的流资源
文件名:库/Email.php
行号:1846
此错误的一些答案“激活 php_openssl”。但我没有使用 ssl(而且我不能)。