无法发送AUTH LOGIN命令。错误:530 5.7.0必须首先发出STARTTLS命令

问题描述 投票:0回答:2

我有以下代码

            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'] = '[email protected]';
            $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('[email protected]', 'Sender');
            $this->email->to('[email protected]');

            $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');

在我的控制器的构造函数中。但是我无法从localhost发送电子邮件。什么是发送电子邮件的解决方案?我需要做出哪些改变?

php codeigniter smtp gmail starttls
2个回答
1
投票

我认为您应该在Gmail帐户中设置“启用IMAP”选项。

它位于“邮件”选项中。

并将您的端口更改为465 ...

$ config ['smtp_port'] ='587';

$ config ['smtp_port'] ='465';

祝好运...


2
投票
$config['protocol'] = 'smtp';
$config['smtp_host'] = 'ssl://smtp.gmail.com';
$config['smtp_port'] = '465';
© www.soinside.com 2019 - 2024. All rights reserved.