Sahil Jariwala Sahil Jariwala - 1 month ago 19
PHP Question

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

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?

Answer

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

Good Luck...

Comments