我刚刚发现我无法再使用CodeIgnier通过本地主机(MAMP)发送邮件。我没有改变配置,唯一真正发生的是系统重启。以下是报告的错误和我的配置,感谢任何帮助。
A PHP Error was encountered
Severity: Warning
Message:
1: fsockopen(): SSL: crypto enabling timeout
2: fsockopen(): Failed to enable crypto
3: fsockopen(): unable to connect to ssl://smtp.googlemail.com:465 (Unknown error)
4: fwrite() expects parameter 1 to be resource, boolean given
5: fgets() expects parameter 1 to be resource, boolean given
6: fwrite() expects parameter 1 to be resource, boolean given
5 & 6 are repeated multiple times
Filename: libraries/Email.php
邮件配置
$config = Array(
'protocol' => 'smtp',
'smtp_host' => 'ssl://smtp.googlemail.com',
'smtp_port' => 465,
'smtp_user' => 'mymail@gmail.com',
'smtp_pass' => 'my_password',
'mailtype' => 'html',
'charset' => 'iso-8859-1',
'wordwrap' => TRUE);
邮件发送
$this->load->library('email', $config);
$this->email->set_newline("\r\n");
$this->email->from('mymail@gmail.com');
$this->email->to('mymail@gmail.com');
$this->email->subject('Test subject');
$this->email->message($message);
答案 0 :(得分:0)
请尝试以下
$config = Array(
'protocol' => 'smtp',
'smtp_host' => 'ssl://smtp.googlemail.com',
'smtp_port' => 465,
'smtp_user' => 'xxx',
'smtp_pass' => 'xxx',
'mailtype' => 'html',
'charset' => 'iso-8859-1'
);
$this->load->library('email', $config);
$this->email->set_newline("\r\n");
// Set to, from, message, etc.
$result = $this->email->send();
并在Sending email with gmail smtp with codeigniter email library
了解更多详情