我希望使用Gmail的smtp发送用户信息到注册的电子邮件。gmail smtp不工作在我的托管使用codeigniter框架
我使用的代码在我的本地主机上正常工作,但是当我更改为共享主机时,出现了以下错误。
A PHP Error was encountered
Severity: Warning
Message: fsockopen() [function.fsockopen]: unable to connect to ssl://smtp.googlemail.com:465 (Connection timed out)
Filename: libraries/Email.php
Line Number: 1652
A PHP Error was encountered
Severity: Warning
Message: fwrite(): supplied argument is not a valid stream resource
Filename: libraries/Email.php
Line Number: 1795
.... (more error msg here)
An Error Was Encountered
The following SMTP error was encountered: 110 Connection timed out
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
.... (more error msg here)
这里是我的电子邮件配置
$pass = $this->generatePassword('6'); $config = Array( 'protocol' => 'smtp', 'smtp_host' => 'ssl://smtp.googlemail.com', 'smtp_port' => 465, 'smtp_timeout'=>'30', 'smtp_user' => '[email protected]', 'smtp_pass' => 'mypassword', 'mailtype' => 'html', 'charset' => 'iso-8859-1' ); $this->load->library('email', $config); $this->email->set_newline("\r\n"); $this->email->from('[email protected]','Title'); $this->email->to($this->input->post('email')); $this->email->subject('Subject here'); $this->email->message('Your login username is '.$this->input->post('username').'<br/>'.'Password is '.$pass); if (!$this->email->send()){ show_error($this->email->print_debugger()); }else{ echo 'YEAH!!!';}
我尝试检查我的份额托管的OpenSSL是否被启用。我发现这个
OpenSSL的 OpenSSL的支持启用
的OpenSSL版本的OpenSSL 0.9.8e - FIPS的RHEL5 2008
7月01日如果OpenSSL是启用。仍然会是我的代码中的错误?
我开始感到沮丧,使用我的本地主机开发,当它上传到共享主机,它出来机智很多错误。
任何帮助将不胜感激! thx in advanced
嗨,TQ你的答案。 我刚问过我的共享主机提供商。他们说他们没有启用端口465,现在他们启用它。我尝试使用Joomla 1.6来测试它现在可用的gmail smtp。但我尝试2在我的codeigniter网站测试它,当我点击注册按钮时,我的网站没有响应。和页面就像继续加载...这是否意味着我Nid 2清除任何cookie或重置任何东西? – 2011-06-11 01:17:22
好的。我关闭浏览器并重新打开。现在它可以工作。谢谢 !! – 2011-06-11 01:25:45
thanx代码 – 2012-06-28 08:49:03