dongzhuo8210
2018-05-15 12:58
浏览 239
已采纳

codeigniter显示stream_socket_client():无法在sendmail上启用加密此错误?

I am trying to send email with code igniter with xampp server on my local machine but its not working. it shows me some errors that i searched alot on net but i am helpless now all solutions that i tried are failed for me.

below are my 3 errors:

Message: stream_socket_client(): SSL: The operation completed successfully.

Message: stream_socket_client(): Failed to enable crypto

Message: stream_socket_client(): unable to connect to ssl://smtp.gmail.com:587 (Unknown error)

this is my php code:

$config = Array(
        'protocol'  => 'smtp',
        'smtp_host' => 'ssl://smtp.gmail.com',
        'smtp_port' => '587',
        'smtp_user' => 'mygmailid@gmail.com',
        'smtp_pass' => 'xxxmypassword',
        'mailtype'  => 'html',
        'starttls'  => true,
        'newline'   => "
"
                    );
        $message = '';
        $this->load->library('email', $config);
        $this->email->set_newline("
");
        $this->email->initialize($config);
        $this->email->from('mygmailid@gmail.com');
        $this->email->to('mygmailid@gmail.com');
        $this->email->subject('Resume from JobsBuddy for your Job posting');
        $this->email->message($message);
      if($this->email->send())
        {
          echo 'Email sent.';
        }
     else
        {
         show_error($this->email->print_debugger());
        }

on print_debugger i get this error too:

The following SMTP error was encountered: 0 Unable to send email using PHP SMTP. Your server might not be configured to send mail using this method.

This is a multi-part message in MIME format. Your email application may not support this format.

please guide me with proper solution.

图片转代码服务由CSDN问答提供 功能建议

我正在尝试使用xampp服务器在我的本地计算机上发送带代码点火器的电子邮件,但它无效。 它向我展示了我在网上搜索过的一些错误,但是现在我尝试的所有解决方案对我都失败了。

下面是我的3个错误: \ n

消息:stream_socket_client():SSL:操作成功完成。

消息:stream_socket_client():无法启用加密

消息:stream_socket_client():无法连接到ssl://smtp.gmail.com:587(未知错误) \ n

这是我的PHP代码:

  $ config = Array(
'protocol'=>'smtp',
'smtp_host'=&gt  ;'ssl://smtp.gmail.com',
'smtp_port'=>'587',
'smtp_user'=>'mygmailid@gmail.com',
'smtp_pass'=>'  xxxmypassword',
'mailtype'=>'html',
'starttls'=> true,
'newline'=>“
 
”
); 
 $ message =''  ; 
 $ this-> load-> library('email',$ config); 
 $ this-> email-> set_newline(“
 
”); 
 $ this-  > email-> initialize($ config); 
 $ this-> email-> from('mygmailid@gmail.com'); 
 $ this-> email-> to('mygmailid @  gmail.com'); 
 $ this-> email-> subject('从JobBuddy恢复为你的职位发布'); 
 $ this-> email-> message($ message); 
 if  ($ this-> email-> send())
 {
 echo'Email sent。'; 
} 
 else 
 {
 show_error($ this-> email-> print_debugger(  print_debugger上的)); 
} 
   
 
 

我也得到这个错误:

以下的SMTP错误是 遇到:0 无法使用PHP SMTP发送电子邮件。 您的服务器可能未配置为使用此方法发送邮件。

这是MIME格式的多部分邮件。 您的电子邮件应用程序可能不支持此 格式。

请指导我找到合适的解决方案。

  • 写回答
  • 好问题 提建议
  • 追加酬金
  • 关注问题
  • 邀请回答

1条回答 默认 最新

  • duancashi1362 2018-05-15 13:28
    最佳回答

    You email config should look something like this:

    $config = Array(
      'protocol'  => 'smtp',
      'smtp_host' => 'ssl://smtp.gmail.com',
      'smtp_port' => 465,
      'smtp_user' => 'YOUR_USERNAME',
      'smtp_pass' => 'YOUR_PASSWORD',
      'mailtype'  => 'html',
      'charset'   => 'utf-8',
      'newline'   => "
    ",
      'wordwrap'  => TRUE,
    );
    

    And like Sandeep J Patel said in his comment, you will also need to enable access for less secure apps in your gmail account settings.

    See their help page about that: https://support.google.com/accounts/answer/6010255?hl=en

    评论
    解决 无用
    打赏 举报

相关推荐 更多相似问题