邮件不从托管的codeigniter应用程序发送

时间:2015-12-20 13:00:41

标签: php codeigniter smtp gmail

Gmail smtp在localhost中成功配置,但移动到godaddy服务器后,同样的事情在远程工作。它不会从应用程序发送任何邮件。

这是我的gmail smtp配置。

$config ['protocol'] = 'smtp';
$config ['smtp_host'] = 'ssl://smtp.gmail.com';
$config ['smtp_port'] = '465';
$config ['smtp_user'] = 'xxx@gmail.com';
$config ['smtp_pass'] = 'xxxx';
$config ['mailtype'] = 'html';
$config ['charset'] = 'iso-8859-1';
$config ['wordwrap'] = TRUE;
$config ['newline'] = "\r\n";

1 个答案:

答案 0 :(得分:1)

试试这个:

function send_email(){
$config = array(
            'protocol' => 'smtp',
              'smtp_host' => 'ssl://smtp.gmail.com',
              'smtp_port' => 465,
             'smtp_user' => 'adc@gmail.com', // change it to yours
             'smtp_pass' => 'adcxc', // change it to yours
             'mailtype' => 'html',
             'charset' => 'UTF-8',
             'wordwrap' => TRUE
          ); 
        $this->load->library('email',$config);
        $this->email->set_newline("\r\n");
        $this->email->from(abc@gmail.com);
        $this->email->to(xyz@gmail.com);


        $this->email->subject("test");
        $this->email->message("message");

        $result = $this->email->send();


        if ($result) {
            echo  "Success";

        }
        else{
            echo $this->email->print_debugger();
        }
}