Send email by Email Class in codeigniter with Gmail

前端 未结 3 1666
走了就别回头了
走了就别回头了 2020-12-03 12:58

I want send a email by Email Class in codeigniter with gmail, but i get following error:

Error:

A PHP Error was encountered
Severity: Wa

相关标签:
3条回答
  • 2020-12-03 13:42

    This is working for me on localhost:

    <?php
         class Email extends CI_controller
         {
            function index()
            {
    
             $this->load->library('email');
             $this->load->helper('url');
             $this->load->helper('form');
    
            $config= Array(
                'protocol'  =>'localhost',
                'smtp_host' => 'localhost',
                'smtp_port' => 'localhost',
                'smtp_user'=>  'root',
                'smtp_pass' =>''
                );
    
            $this->load->library('email','$config');
            $this->email->set_newline("\r\n");
            $this->email->from('nisha@gmail.com','nisha');
            $this->email->to('cse1473@gmail.com');
            $this->email->subject('this is email with subject');
            $this->email->message('it s working properly');
    
            if($this->email->send())
            {
                echo "your email send";
            }
            else
            {
                show_error($this->email->print_debugger());
            }
        }
    }
    
    ?>
    
    0 讨论(0)
  • 2020-12-03 13:52

    this is what worked for me

    $email_config = Array(
                'protocol'  => 'smtp',
                'smtp_host' => 'ssl://smtp.googlemail.com',
                'smtp_port' => '465',
                'smtp_user' => 'someuser@gmail.com',
                'smtp_pass' => 'password',
                'mailtype'  => 'html',
                'starttls'  => true,
                'newline'   => "\r\n"
            );
    
            $this->load->library('email', $email_config);
    
            $this->email->from('someuser@gmail.com', 'invoice');
            $this->email->to('test@test.com');
            $this->email->subject('Invoice');
            $this->email->message('Test');
    
            $this->email->send();
    
    0 讨论(0)
  • 2020-12-03 13:59

    Have you turned on php_openssl?

    Try to uncomment extension=php_openssl.dll in your php.ini file.

    0 讨论(0)
提交回复
热议问题