public function reset()
{
$config=array(
'protocol'=> 'smtp',
'smtp_host'=> 'ssl://smtp.googlemail.com',
'smtp_user'=> 'xxxxx',
'smtp_pass'=> 'xxxxx',
'smtp_port'=> 465,
'mailtype' => 'html',
'charset' => 'iso-8859-1'
);
$this->load->library('email',$config);
$this->email->set_newline("\r\n");
$this->email->from('abc@gmail.com','abc');
$this->email->to('abc@gmail.com');
$this->email->subject('Password Reset');
$this->email->message('U have request new password, Here is the new password:');
if( $this->email->send())
{
echo('mail is send successfully');
}
else
{
echo("Error in Email sending");
}
// redirect('http://localhost/p_test/index.php/login/forget');
}
显示以下错误
A PHP Error was encountered
Severity: Warning
Message: fsockopen(): unable to connect to ssl://smtp.googlemail.com:465 (Unable to find the socket transport "ssl" - did you forget to enable it when you configured PHP?)
Filename: libraries/Email.php
Line Number: 1689
A PHP Error was encountered
Severity: Warning
Message: fwrite() expects parameter 1 to be resource, boolean given
Filename: libraries/Email.php
Line Number: 1846
A PHP Error was encountered
Severity: Warning
Message: fgets() expects parameter 1 to be resource, boolean given
Filename: libraries/Email.php
Line Number: 1869
A PHP Error was encountered
Severity: Warning
Message: fwrite() expects parameter 1 to be resource, boolean given
Filename: libraries/Email.php
Line Number: 1846
A PHP Error was encountered
Severity: Warning
Message: fgets() expects parameter 1 to be resource, boolean given
Filename: libraries/Email.php
Line Number: 1869
A PHP Error was encountered
Severity: Warning
Message: fwrite() expects parameter 1 to be resource, boolean given
Filename: libraries/Email.php
Line Number: 1846
A PHP Error was encountered
Severity: Warning
Message: fgets() expects parameter 1 to be resource, boolean given
Filename: libraries/Email.php
Line Number: 1869
A PHP Error was encountered
Severity: Warning
Message: fwrite() expects parameter 1 to be resource, boolean given
Filename: libraries/Email.php
Line Number: 1846
A PHP Error was encountered
Severity: Warning
Message: fgets() expects parameter 1 to be resource, boolean given
Filename: libraries/Email.php
Line Number: 1869
A PHP Error was encountered
Severity: Warning
Message: fwrite() expects parameter 1 to be resource, boolean given
Filename: libraries/Email.php
Line Number: 1846
A PHP Error was encountered
Severity: Warning
Message: fwrite() expects parameter 1 to be resource, boolean given
Filename: libraries/Email.php
Line Number: 1846
A PHP Error was encountered
Severity: Warning
Message: fgets() expects parameter 1 to be resource, boolean given
Filename: libraries/Email.php
Line Number: 1869
Error in Email sending
答案 0 :(得分:1)
使用此:
protocol = smtp
smtp_host = smtp.gmail.com
smtp_port = 465
smtp_crypto = ssl
smtp_user = your user
smtp_pass = your pass
这是我在CodeIgniter中使用Gmail发送邮件的方式。