使用codeigniter php发送电子邮件

时间:2018-03-24 05:32:49

标签: php codeigniter

严重性:警告

消息:mail():无法连接到“localhost”端口25的邮件服务器,验证php.ini中的“SMTP”和“smtp_port”设置或使用ini_set()

文件名:libraries / Email.php

行号:1894

回溯:

文件:C:\ xampp \ htdocs \ prmadmin \ application \ controllers \ Email.php 行:49 功能:发送

文件:C:\ xampp \ htdocs \ prmadmin \ index.php 行:315 功能:require_once

1 个答案:

答案 0 :(得分:0)

你可以试试这个:

public function send_mail(){
    $this->load->library('email');
    $to_email = 'abc@gmail.com';
    $from_email = 'xyz@gmail.com';

    $config = array(
                    'charset' => 'utf-8',
                    'wordwrap' => TRUE,
                    'mailtype' => 'html'
                );

    $this->email->initialize($config);

     $this->email->from($from_email);
                $this->email->to($to_email);
                $this->email->subject('Test mail send');
                $this->email->message('Test Mail);

    if($this->email->send()){
    echo "send";
    }else{
    echo "error";
    }
}