Help with sending email using Xampp - michaeldtrek - 08-07-2017
Code: Hi, I'm new at this and am having trouble in getting this to work. I cannot get CI to send email using Xampp and hopefully someone can help. This is what I have done.
In the C:\xampp\php\php.ini I removed the semicolon from extension=php_openssl.dll
-----
In the in php.ini file I changed [mail function] to the following
SMTP=smtp.gmail.com
smtp_port=465
sendmail_from = [email protected]
sendmail_path = "\"C:\xampp\sendmail\sendmail.exe\" -t"
-----
In the sendmail.ini i chnage the following code
[sendmail]
smtp_server=smtp.gmail.com
smtp_port=465
error_logfile=error.log
debug_logfile=debug.log
[email protected]
auth_password=my-gmail-password
[email protected]
-----
This is my code:
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
class Contact extends MX_Controller
{
public function index()
{
$config = Array(
'protocol' => 'smtp',
'smtp_host' =>'ssl://smtp.googleemail.com',
'smtp_port' => 465,
'smtp_user' => '**********@gmail.com',
'smtp_pass' => '**********',
'mailtype' => 'html',
'charset' => 'utf-8',
'wordwrap' => TRUE
);
$this->load->library('email', $config);
$this->email->set_newline("\r\n");
$this->email->from('[email protected]', 'Michael Foston');
$this->email->to('[email protected]');
$this->email->subject('Email Test');
$this->email->message('Testing the email class.');
if($this->email->send())
{
echo 'your email was sent';
}
else
{
echo $this->email->print_debugger();
}
}
}
------
This is the error I am recieving:
Unable to send email using PHP mail(). Your server might not be configured to send mail using this method.
Date: Mon, 7 Aug 2017 20:18:25 +0200
From: "**********" <**********@gmail.com>
Return-Path: <**********@gmail.com>
Reply-To: <**********@gmail.com>
User-Agent: CodeIgniter
X-Sender: **********@gmail.com
X-Mailer: CodeIgniter
X-Priority: 3 (Normal)
Message-ID: <**********@gmail.com>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
=?UTF-8?Q?Email=20Test?=
Testing the email class.
Thanks.
RE: Help with sending email using Xampp - jarmen_kell - 08-07-2017
I don't feel the necessity of sending a mail thru Gmail's SMTP server using Sendmail.
what I usually do, is just uses CI's built-in Email Class library, configure it to use GMAIL's SMTP,
and execute.
https://www.codeigniter.com/user_guide/libraries/email.html#setting-email-preferences-in-a-config-file
and it should work
RE: Help with sending email using Xampp - InsiteFX - 08-08-2017
CodeIgniter : Sending Email via Gmail Using SMTP Protocol
RE: Help with sending email using Xampp - michaeldtrek - 08-11-2017
Thanks, I have a better understanding now.
RE: Help with sending email using Xampp - arugama - 12-28-2017
i have the same issue, can u help me? are u manage to resolve this?
|