在Codeigniter中使用Gmail发送邮件

时间:2017-11-16 06:20:41

标签: php email gmail cpanel codeigniter-3

我会尝试在codeigniter中使用gmail发送邮件。我按照下面的代码编写代码。当我将它上传到c面板上时,它将正常工作2天,但之后就会停止工作。

//Load email library
$this->load->library('email');

//SMTP & mail configuration
$config = array(
    'protocol' => 'smtp',
    'smtp_host' => 'ssl://smtp.googlemail.com',
    'smtp_port' => 465,
    'smtp_user' => 'xxxxxx',
    'smtp_pass' => 'xxxxxx',
    'mailtype'  => 'html',
    'charset'   => 'utf-8'
);
$this->email->initialize($config);
$this->email->set_mailtype('html');
$this->email->set_newline("\r\n");

//Email content
$htmlContent = '<h1>MY WEBSITE</h1>';
$htmlContent .= '<p>OTP For Reset Your Password.</p>';

$this->email->to($uemail);
$this->email->from('xxxxxxxx','MyWebsite');
$this->email->subject('MESSAGE');
$this->email->message($htmlContent);

//Send email
$this->email->send();   

0 个答案:

没有答案