无法使用codeigniter&发送邮件gmail虽然在php.ini中启用了ssl

时间:2012-04-16 09:49:56

标签: php codeigniter gmail

我知道这个问题已经发布但我无法找到问题的答案。 我正在使用codeigniter发送电子邮件,使用gmail服务器。以下是用于此任务的代码:

$config['protocol'] = 'smtp';
$config['smtp_host'] = 'ssl://smtp.googlemail.com';
$config['mail_path'] = 'ssl://smtp.googlemail.com';
$config['smtp_user'] = 'my-email@gmail.com';
$config['smtp_pass'] = '******';
$config['smtp_port'] = '465';
$config['smtp_timeout'] = '30';
$config['mailtype'] = 'text';
$config['charset'] = 'utf-8';
$config['validate'] = TRUE;
$config['crlf'] = '\r\n';
$config['newline'] = '\n\n';

$this->load->library('email',$config);
$this->email->from('my-email@gmail.com');
$this->email->to('another-email');
$this->email->subject('Validation');

$message = "some message";

$this->email->message($message);

$this->email->send();

我使用$this->email->print_debugger()来显示错误。 以下是我收到的消息:

The following SMTP error was encountered: 13 Unable to find the socket transport "ssl" -
did you forget to enable it when you configured PHP?
Unable to send data: AUTH LOGIN
Failed to send AUTH LOGIN command. Error: 
Unable to send data: MAIL FROM:
from: 
The following SMTP error was encountered: 
Unable to send data: RCPT TO:
to: 
The following SMTP error was encountered: 
Unable to send data: DATA
data: 
The following SMTP error was encountered: ...

当然,我在php.ini文件中取消了与SSL对应的行...

有什么想法吗?

谢谢:)

1 个答案:

答案 0 :(得分:0)

NetTuts上有一个关于这个主题的好教程。 以下是指向它的链接:http://net.tutsplus.com/articles/news/codeigniter-from-scratch-day-3/

源代码可下载。