mediatemple - can't send email using codeigniter

前端 未结 2 1631
猫巷女王i
猫巷女王i 2021-01-26 03:33

I can\'t send emails using mediatemple in codeigniter.I\'ve checked the email password and smtp host and they are correct.

This is the error:

Severity: N         


        
2条回答
  •  再見小時候
    2021-01-26 04:13

    You need to initialise the the config, see the codeigniter documentation for the email class.

    Here is my example which works well...

        function send_email($attributes) {
    
            $this->load->library('email');
    
            $this->email->set_newline("\r\n");
    
            $config['protocol'] = 'smtp';
            $config['smtp_host'] = 'host';
            $config['smtp_port'] = '465';
            $config['smtp_user'] = 'user@smtp.com';
            $config['smtp_from_name'] = 'FROM NAME';
            $config['smtp_pass'] = 'XXX';
            $config['wordwrap'] = TRUE;
            $config['newline'] = "\r\n";
            $config['mailtype'] = 'html';                       
    
            $this->email->initialize($config);
    
            $this->email->from($config['smtp_user'], $config['smtp_from_name']);
            $this->email->to($attributes['to']);
            $this->email->cc($attributes['cc']);
            $this->email->bcc($attributes['cc']);
            $this->email->subject($attributes['subject']);
    
            $this->email->message($attributes['message']);
    
            if($this->email->send()) {
                return true;        
            } else {
                return false;
            }       
    
    }
    

提交回复
热议问题