0

I am having the following code

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

But when the code executes, I am getting the following error

Failed to send AUTH LOGIN command. Error: 530 5.7.0 Must issue a STARTTLS command first. qd9sm8462833pbb.31

I have used

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

in my controller's constructor. But I am unable to send email from localhost. What can be the solution to send email? What changes do I need to make?

4

3 に答える 3

4
$config['protocol'] = 'smtp';
$config['smtp_host'] = 'ssl://smtp.gmail.com';
$config['smtp_port'] = '465';
于 2016-10-30T15:16:11.253 に答える
1

I think you should set "Enable IMAP" option in your Gmail account.

It is in the Mail options.

And change your port to 465 ...

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

to

$config['smtp_port'] = '465';
于 2013-08-06T21:30:27.343 に答える
0

Add:

$config['smtp_crypto'] = 'tls'; // or html
于 2020-07-22T14:03:21.050 に答える