【问题标题】:how to resolve error in sending mail using php如何解决使用php发送邮件的错误
【发布时间】:2018-05-23 20:47:51
【问题描述】:

我正在开发 php 框架 codeigniter,电子邮件没有在本地主机上发送我还从我用来发送邮件的防病毒软件中删除了端口 465,并且还关闭了防病毒软件它给出了错误 " fsockopen(): SSL 操作失败,代码为 1", fsockopen():启用加密失败

$config['protocol']  = 'smtp';
  $config['smtp_host'] = 'ssl://smtp.googlemail.com';
  $config['smtp_port'] = 465;
  $config['smtp_user'] = '*******@gmail.com'; // change it to yours
  $config['smtp_pass'] = '******'; // change it to yours
  $config['charset'  ] = 'iso-8859-1';
  $config['newline'  ] = "\r\n";

  $config['mailtype' ] = 'text';

  $config['validation' ] = TRUE;
   $this->load->library('email',$config);



    $this->email->from('*********@gmail.com');
    $this->email->to('********@gmail.com');   
    $this->email->subject('Confirmation Email');                                       
    $this->email->message('Thank you');                    

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


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

这是我做的代码,你能解决这个问题吗?

【问题讨论】:

    标签: php email


    【解决方案1】:

    试试这个

    使用ssl://smtp.gmail.com

    $config = Array(
                'protocol' => 'smtp',
                'smtp_host' => 'ssl://smtp.gmail.com',
                'smtp_port' => 465,
                'smtp_user' => '*************@gmail.com', // change it to yours
                'smtp_pass' => '******', // change it to yours
                'mailtype' => 'html',
                'charset' => 'iso-8859-1',
                'wordwrap' => TRUE
              );
                   $this->load->library('email', $config);
                   $this->email->set_newline("\r\n");  
                   $this->email->from('***@gmail.com'); // change it to yours
                   $this->email->to('***@gmail.com');// change it to yours
                   $this->email->subject('Confirmation Email');
                   $this->email->message('Thank you');
                 if($this->email->send())
                 {
                  /* echo 'Email sent.';*/
    
                echo "send successfully";
    
                 }
                 else
                 {
                  show_error($this->email->print_debugger());
                 }
    

    仍然面临同样的问题,然后试试这个链接GMail fsockopen(): SSL operation failed error with Codeigniter and XAMPP

    【讨论】:

    • @MuhammadShareyar,在尝试了我的代码后,您遇到了什么错误?
    • xampp->php->php.ini。打开您的 php.ini 文件,找到 ;extension=php_openssl.dll 并从该行中删除分号,保存并重新启动您的服务器
    猜你喜欢
    • 1970-01-01
    • 2019-03-29
    • 2022-06-14
    • 2016-08-30
    • 2016-07-01
    • 2015-03-02
    • 2010-10-18
    • 2023-04-05
    • 2017-09-24
    相关资源
    最近更新 更多