gmail smtp不工作在我的主机使用codeigniter框架 [英] gmail smtp not working in my hosting using codeigniter framework

查看:776
本文介绍了gmail smtp不工作在我的主机使用codeigniter框架的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我希望使用gmail smtp将用户信息发送到注册的电子邮件。



我使用的代码在我的本地主机中正常工作,但当我改变为共享主机时,出现以下错误。



遇到PHP错误
严重性:警告

消息:fsockopen()[function.fsockopen]:无法连接到ssl://smtp.googlemail.com:465(连接超时)

文件名:libraries / Email.php

行号:1652

遇到PHP错误
严重性:警告

消息:fwrite():提供的参数不是有效的流资源

文件名:libraries /电子邮件.php

行号:1795

....(更多错误msg here)

遇到错误
以下遇到SMTP错误:110连接超时
无法发送数据:AUTH LOGIN
无法发送AUTH LOGIN命令。错误:
无法发送数据:MAIL FROM:


从:
遇到以下SMTP错误:
无法发送数据:RCPT TO :

到:
遇到以下SMTP错误:
无法发送数据:DATA

....(更多错误msg here)

这是我的电子邮件配置



  $ pass = $ this-> generatePassword('6'); 

$ config = Array(
'protocol'=>'smtp',
'smtp_host'=>'ssl://smtp.googlemail.com',
'smtp_port'=> 465,
'smtp_timeout'=> '30',
'smtp_user'=>'username@gmail.com',
'smtp_pass' =>'mypassword',
'mailtype'=>'html',
'charset'=>'iso-8859-1'
);
$ this-> load-> library('email',$ config);
$ this-> email-> set_newline(\r\\\
);

$ this-> email-> from('admin@lalala.com','Title');
$ this-> email-> to($ this-> input-> post('email'));

$ this-> email-> subject('Subject here');
$ this-> email-> message('您的登录用户名为'。$ this-> input-> post('username')。'< br />'。 '。$ 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。仍然会是我的代码中的错误?



我开始对使用我的localhost进行开发感到沮丧,当它上传到共享主机时,它出了很多错误。



任何帮助将不胜感激! thx in advanced

解决方案

看起来像共享主机中的ssl端口关闭,
使用此代码检查是开放的。

  $ fp = fsockopen(www.google.com,80,& $ errno,& $ errstr,10); // work fine 
if(!$ fp)
echowww.google.com - $ errstr($ errno)< br> \\\
;
else
echowww.google.com - ok< br> \\\
;


$ fp = fsockopen(smtp.gmail.com,465,& $ errno,& $ errstr,10); // NOT work
if(!$ fp)
echosmtp.gmail.com 465 - $ errstr($ errno)< br> \\\
;
else
echosmtp.gmail.com 465 - ok< br> \\\
;


$ fp = fsockopen(smtp.gmail.com,587,& $ errno,& $ errstr,10); // NOT work
if(!$ fp)
echosmtp.gmail.com 587 - $ errstr($ errno)< br> \\\
;
else
echosmtp.gmail.com 587 - ok< br> \\\
;


i wish to use gmail smtp to send user information to the registered email.

The code that i am using is working fine in my localhost, but when i changed into shared hosting it come out with the below error.

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)

Here's my email config

$pass = $this->generatePassword('6');

$config = Array(
  'protocol' => 'smtp',
  'smtp_host' => 'ssl://smtp.googlemail.com',
  'smtp_port' => 465,
  'smtp_timeout'=>'30',
  'smtp_user' => 'username@gmail.com',
  'smtp_pass' => 'mypassword',
  'mailtype'  => 'html',
  'charset'   => 'iso-8859-1'
);
$this->load->library('email', $config);
$this->email->set_newline("\r\n");

$this->email->from('admin@lalala.com','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!!!';}

i try to check my share hosting openssl whether is enabled or not. and i found this

openssl OpenSSL support enabled
OpenSSL Version OpenSSL 0.9.8e-fips-rhel5 01 Jul 2008

If openssl is enabled. still what will be the mistake in my code?

I start to be frustrated to use my localhost to develop and when its uploaded to share hosting, it came out wit lots of error.

Any help would be appreciate!! thx in advanced

解决方案

Looks like ur ssl port in shared hosting is close, use this code to check if it is open.

$fp = fsockopen("www.google.com", 80, &$errno, &$errstr, 10); // work fine
if (!$fp)
    echo "www.google.com -  $errstr   ($errno)<br>\n";
else
    echo "www.google.com -  ok<br>\n";


$fp = fsockopen("smtp.gmail.com", 465, &$errno, &$errstr, 10); // NOT work
if (!$fp)
    echo "smtp.gmail.com 465  -  $errstr   ($errno)<br>\n";
else
    echo "smtp.gmail.com 465 -  ok<br>\n";


$fp = fsockopen("smtp.gmail.com", 587, &$errno, &$errstr, 10); // NOT work
if (!$fp)
    echo "smtp.gmail.com 587  -  $errstr   ($errno)<br>\n";
else
    echo "smtp.gmail.com 587 -  ok<br>\n";

这篇关于gmail smtp不工作在我的主机使用codeigniter框架的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆