我有以下代码
ini_set("SMTP","ssl://smtp.gmail.com");
ini_set("smtp_port","587");
$config['protocol'] = 'smtp';
$config['smtp_host'] = 'smtp.gmail.com';
$config['smtp_port'] = '587';
$config['_smtp_auth']=TRUE;
$config['smtp_user'] = 'sender@gmail.com';
$config['smtp_pass'] = 'password';
$config['smtp_timeout'] = '60';
$config['charset'] = 'utf-8';
$config['wordwrap'] = TRUE;
$config['mailtype'] = "html";
$this->email->initialize($config);
$this->email->from('sender@gmail.com', 'Sender');
$this->email->to('receiver@gmail.com');
$this->email->subject('This is my subject');
$this->email->message('This is the content of my message');
if ( ! $this->email->send())
{
show_error($this->email->print_debugger());
}
else
{
echo('DONE');
}
但是当代码执行时,我收到以下错误
发送 AUTH LOGIN 命令失败。错误:530 5.7.0 必须先发出 STARTTLS 命令。qd9sm8462833pbb.31
我用过
$this->load->library('email');
在我的控制器的构造函数中。但我无法从本地主机发送电子邮件。发送电子邮件的解决方案是什么?我需要做哪些改变?