3

我正在尝试使用 CI 创建一个电子邮件通知系统。问题是我正在使用的系统阻止了 gmail。所以,我无法使用 gmail SMTP。现在,我必须想办法用 hotmail 或任何其他 SMTP 服务发送电子邮件。这是我的代码,它适用于 gmail,但现在适用于 hotmail config/Email.php:

$config = array(
    'protocol' => 'smtp', 
    'smtp_host' => 'ssl://smtp.live.com',
    'smtp_port' => 587,
    'smtp_user' => 'muttalebr@hotmail.com',
    'smtp_pass' => 'XXXXXX',
    'charset' => 'utf-8',
 'newline' => "\r\n",
 'crlf' => "\r\n",
 'mailtype' => "html",


); 

调用 email.php 并发送电子邮件的实际函数:

function sends($from,$to,$send,$user){
   $link=base_url()."index.php/anonymouscoll/cmembersarea/".$user;
   $emailmessage="Hello $to,<br />You have a new Gift from $from.<br />Click on the link:<a href=$link>$link</a> to check your gift.<br /><br /><br />Best Regards<br />Online Communication.";
   $this->load->library('email');
   $this->email->from('muttalebr@hotmail.com','Gift File');
   $this->email->to($send);
   $this->email->subject('You have a new Gift');
   $this->email->message($emailmessage);

   if($this->email->send()){
    echo "Email sent";

   }
   else{
    show_error($this->email->print_debugger());
   } 

每次我调用“发送”函数时,都会出现以下错误:

Severity: Warning

Message: fsockopen() [function.fsockopen]: SSL operation failed with code 1. OpenSSL Error messages: error:140770FC:SSL routines:SSL23_GET_SERVER_HELLO:unknown protocol

Filename: libraries/Email.php

Line Number: 1673 
and

Severity: Warning

Message: fsockopen() [function.fsockopen]: Failed to enable crypto

Filename: libraries/Email.php

Line Number: 1673 

我也试过

'smtp_host' => 'sslv2://smtp.live.com',

但它不能在我的本地机器上工作。我在本地机器上使用 Windows 7,在系统上使用 Windows Xp,我将使用该应用程序[阻止 gmail 的那个]。我尝试使用 XAMPP 1.8.1 版和 WAMPP 2.2 版

期待您的回复

~muttalebm

4

2 回答 2

1

您使用的是哪个版本的 PHP?

在某些版本中,fsockopen ssl 显然存在一个错误:

https://bugs.php.net/bug.php?id=54511

于 2012-12-18T08:20:12.680 回答
1

错误是因为您没有在 php.info 文件中启用 SSL。所以搜索如何启用它。否则,您可以在下面的链接中查看我对问题的回答,这与此相同。我在做的时候遇到了这个错误,我解决了。

参考链接

于 2012-12-05T06:34:09.020 回答