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

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.

  • 写回答

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

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 关于#matlab#的问题:在模糊控制器中选出线路信息,在simulink中根据线路信息生成速度时间目标曲线(初速度为20m/s,15秒后减为0的速度时间图像)我想问线路信息是什么
  • ¥15 banner广告展示设置多少时间不怎么会消耗用户价值
  • ¥16 mybatis的代理对象无法通过@Autowired装填
  • ¥15 可见光定位matlab仿真
  • ¥15 arduino 四自由度机械臂
  • ¥15 wordpress 产品图片 GIF 没法显示
  • ¥15 求三国群英传pl国战时间的修改方法
  • ¥15 matlab代码代写,需写出详细代码,代价私
  • ¥15 ROS系统搭建请教(跨境电商用途)
  • ¥15 AIC3204的示例代码有吗,想用AIC3204测量血氧,找不到相关的代码。