gmail smtp 无法在我的主机中使用 codeigniter 框架工作

发布于 2024-11-14 19:39:21 字数 2145 浏览 1 评论 0原文

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

我正在使用的代码在我的本地主机中运行良好,但是当我更改为共享托管时,会出现以下错误。

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');

$配置=数组(
  '协议' => 'smtp',
  'smtp_host' =>; 'ssl://smtp.googlemail.com',
  'smtp_端口' => 465、
  'smtp_timeout'=>'30',
  'smtp_user'=>; '[电子邮件受保护]',
  'smtp_pass' =>; '我的密码',
  '邮件类型' => 'html',
  '字符集' => 'iso-8859-1'
);
$this->load->library('email', $config);
$this->电子邮件->set_newline("\r\n");

$this->email->from('[电子邮件受保护] ','标题');
$this->email->to($this->input->post('email'));

$this->电子邮件->主题('此处主题');
$this->email->message('您的登录用户名是 '.$this->input->post('用户名').'
'.'密码是 '.$pass ); if (!$this->电子邮件->send()){ show_error($this->电子邮件->print_debugger()); }其他{回显'是的!!!';}

我尝试检查我的共享托管 openssl 是否已启用。我发现了这个

openssl 已启用 OpenSSL 支持
OpenSSL 版本 OpenSSL 0.9.8e-fips-rhel5 2008 年 7 月 1 日

如果 openssl 已启用。我的代码中仍然会出现什么错误?

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

任何帮助将不胜感激!谢谢提前

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' => '[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!!!';}

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

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

筱果果 2024-11-21 19:39:21

看起来共享主机中的 ssl 端口很接近,
使用此代码检查它是否打开。

$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";

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";
吾性傲以野 2024-11-21 19:39:21

较新的 php 中的测试脚本有更新
版本:

<?php

    $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";



?>

there is update for test script in newer php
version:

<?php

    $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";



?>
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文