php - 使用 CodeIgniter 通过 Gmail 发送电子邮件时遇到问题?

标签 php email codeigniter gmail

我正在尝试通过我的 Gmail 帐户在 codeigniter 中发送电子邮件。我当前的代码如下所示:

$config = Array(
     'protocol' => 'smtp',
     'smtp_host' => 'ssl://smtp.googlemail.com',
     'smtp_port' => 465,
     'smtp_user' => 'me@gmail.com',
     'smtp_pass' => 'my_gmail_password',
     'mailtype'  => 'html',
     'charset'   => 'iso-8859-1'
);

$this->load->library('email', $config);
$this->email->set_newline("\r\n");
$this->email->from('me@gmail.com', 'Me');
$this->email->to("me@gmail.com");
$this->email->subject('A test email from CodeIgniter using Gmail');
$this->email->message("A test email from CodeIgniter using Gmail");

$this->email->send();

但是,这给了我以下错误:

Message: fsockopen() [function.fsockopen]: unable to connect to ssl://smtp.googlemail.com:465 (Connection timed out)
Filename: libraries/Email.php

Message: fwrite(): supplied argument is not a valid stream resource

Message: fgets(): supplied argument is not a valid stream resource

如果能帮助解决这个问题,我们将不胜感激!谢谢!

注意:我可以向您保证我的 Gmail 电子邮件和密码是正确的

最佳答案

该错误表示您无法连接您输入的 SMTP 地址。

你应该使用:smtp.gmail.com

检查以下链接以供引用: http://mail.google.com/support/bin/answer.py?answer=13287

关于php - 使用 CodeIgniter 通过 Gmail 发送电子邮件时遇到问题?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7090457/

相关文章:

php邮件不工作

php - 从 session 中获取用户数据 Codeigniter

php - 如何在 phpword 和 Codeigniter 中每 4 列创建新行?

php - 避免由于页面刷新而提交的最佳方法

php - 使用 PHP + MySQL 的最佳开发设置是什么?

php - 找不到包装器 "https"- 您在配置 PHP 时是否忘记启用它?

mysql - 如何获取值列在codeigniter 3中的列

php - 更简洁的三元表达式?

java - 一封电子邮件可以包含多个消息 ID 吗?

email - 设置 mailgun 的 "reply-to" header 字段