如何使用密码点火器发送邮件


how to sending mail Using Codigniter?

我正试图使用codeigniter实现发送电子邮件的功能,但它不起作用,什么都没发送,有什么帮助吗?

这是我的控制器:

public function send_mail() { 
     $this->load->library('session'); 
     $this->load->helper('form'); 
     $this->load->view('admin/main/email_form.php');
    $config = Array(
    'protocol' => 'smtp',
    'smtp_host' => 'ssl://smtp.googlemail.com',
    'smtp_port' => 465,
    'smtp_user' => 'xxxxxx@gmail.com', 
    'smtp_pass' => 'xxxxxx',
    'mailtype' => 'html',
    'charset' => 'iso-8859-1',
    'wordwrap' => TRUE);
     $from_email = "xxxxxxx@gmail.com"; 
     $to_email = $this->input->post('email'); 
     $subject  = $this->input->post('subject');
     $message = $this->input->post('message');
     $this->load->library('email',$config); 
     $this->email->set_newline("'r'n");
     $this->email->from($from_email); 
     $this->email->to($to_email);
     $this->email->subject($subject); 
     $this->email->message($message);
     $this->email->send();       
  }     

试试这个并检查服务器的日志:

$config = array(
    'protocol' => 'smtp',
    'smtp_host' => 'smtp.gmail.com',
    'smtp_port' => 465, // or 587
    'smtp_user' => 'xxx@gmail.com',
    'smtp_pass' => 'xxx',
    'charset' => 'utf-8',
    'mailtype' => 'html'
);
$this->load->library('email', $config);
$this->email->from($from_email); 
$this->email->to($to_email);
$this->email->subject($subject); 
$this->email->message($message);
if (!$this->email->send()) {
    echo $this->email->print_debugger();
}

有关更多示例,请查看此问题。

您可以尝试以下代码

        $this->load->library('email');          
        $config['protocol'] = "smtp";
        $config['smtp_host'] = 'mail.domain.com'; //smtp host name
        $config['smtp_port'] = '587'; //smtp port 
        $config['smtp_user'] = 'mail@domain.com'; //smtp username
        $config['smtp_pass'] = '12345'; //smtp password
        $config['mailtype'] = 'html';
        $config['charset'] = 'utf-8';
        $config['newline'] = "'r'n";
        $config['wordwrap'] = TRUE;
        $this->email->initialize($config);          
        $this->email->from('from@gmail.com', 'website.com');
        $this->email->to('to@gmail.com');             
        $msg="This is test message";
        $this->email->subject('Test Subject');
        $this->email->message($msg);
        $this->email->send();