Im trying to send an email from my localhost using xampp to Gmail with Codeigniter.
This is my code in the controller:
public function mail()
{
$config = Array(
'protocol' => 'smtp',
'smtp_host' => 'smtp.gmail.com',
'smtp_port' => 465,
'smtp_user' => 'kingkangddg@gmail.com',
'smtp_pass' => '*****',
'new_line' => "\r\n",
);
$this->load->library('email', $config);
$this->email->set_newline("\r\n");
$this->email->from('kingkangddg@gmail.com', 'Glenn Samporna');
$this->email->to('fajardokarlelbert@gmail.com');
$this->email->subject('Test');
$this->email->message('sample message');
if($this->email->send()){
echo 'sent';
} else {
show_error($this->email->print_debugger());
}
}
It throws out errors like this:
hello: F
The following SMTP error was encountered: F
Unable to send email using PHP SMTP. Your server might not be configured to send mail using this method.
Date: Mon, 29 Jan 2018 09:35:37 +0100
From: "King Kang" <kingkangddg@gmail.com>
Return-Path: <kingkangddg@gmail.com>
To: fajardokarlelbert@gmail.com
Subject: =?UTF-8?Q?Test?=
Reply-To: <kingkangddg@gmail.com>
User-Agent: CodeIgniter
X-Sender: kingkangddg@gmail.com
X-Mailer: CodeIgniter
X-Priority: 3 (Normal)
Message-ID: <5a6edcd99171d@gmail.com>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
sample message
A PHP Error was encountered
Severity: Notice
Message: fwrite(): send of 6 bytes failed with errno=10053 An established connection was aborted by the software in your host machine.
Filename: libraries/Email.php
Line Number: 2242
Backtrace:
I hope you can help me out with this one.