我正在尝试通过我的 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/