如何在Codeigniter中使用Gmail SMTP发送邮件

时间:2019-03-12 10:22:45

标签: codeigniter email smtp

我想通过我的Gmail帐户通过网站发送电子邮件。我怎么做?我尝试了所有可能的方法,但无法获得所需的输出。

public  function mailuser(){
    $config = Array(protocol' => 'ssmtp','smtp_host' => 'ssl://ssmtp.gmail.com','smtp_port' => 465,'smtp_user' => 'xxxx@gmail.com','smtp_pass' => 'xxxx','mailtype'  => 'html');
    $this->load->library('email', $config);
    $this->email->set_newline("\r\n");
    $this->email->from('xxxx@gmail.com', 'Manoj');
    $this->email->to('xxxxx@gmail.com'); 
    $this->email->subject('Email Subject');
    $this->email->message('Email Message');

    if($this->email->send()){
        echo 'Success email Sent';
        echo $this->email->print_debugger();
    }
    else{
        echo 'Email Failed To Send';
        echo $this->email->print_debugger();
    }
}

0 个答案:

没有答案