My email.php
located within config/
folder:
$config['protocol'] = 'smtp';
$config['smtp_host'] = 'smtp.gmail.com';
$config['smtp_port'] = '465';
$config['smtp_user'] = 'gmfernandes@[domain].com';
$config['smtp_pass'] = '[password]';
$config['mailtype'] = 'html';
$config['charset'] = 'utf-8';
$config['wordwrap'] = TRUE;
$config['newline'] = "\r\n";
My email()
method:
public function email()
{
$from_name = $this->input->post('nome_email');
$from_email = $this->input->post('email_email');
$to = 'gmfernandes@[domain].com';
$subject = 'Testing';
$message = $this->input->post('proposta_email');
$this->email->from($from_email, $from_name);
$this->email->to($to);
$this->email->subject($subject);
$this->email->message($message);
if ($this->email->send()) {
echo 'Sent!';
} else {
echo $this->email->print_debugger();
}
die;
}
My autoload.php
:
$autoload['libraries'] = array('database', 'session', 'form_validation', 'email');
I am trying to make this work. I have spent hours looking for a solution but NONE of them helped me. Removed and installed sendmail
and postfix
several times, tried to use default configuration but nothing. It doesn't work with me.
Now, the message that is shown:
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.
User-Agent: CodeIgniter
Date: Mon, 11 Jan 2016 18:11:54 -0200
From: "Gabriel" <mfgabriel@[domain].com>
Return-Path: <mfgabriel@[domain].com>
To: gmfernandes@[domain].com
Subject: =?UTF-8?Q?Testing?=
Reply-To: "mfgabriel@[domain].com" <mfgabriel@[domain].com>
X-Sender: mfgabriel@[domain].com
X-Mailer: CodeIgniter
X-Priority: 3 (Normal)
Message-ID: <56940c8a3846e@[domain].com>
Mime-Version: 1.0
Content-Type: multipart/alternative; boundary="B_ALT_56940c8a384c8"
This is a multi-part message in MIME format.
Your email application may not support this format.
--B_ALT_56940c8a384c8
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Teste
--B_ALT_56940c8a384c8
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
Teste
--B_ALT_56940c8a384c8--
What to do?
Edit #1
After chaning my config.php
file to ssl://smtp.gmail.com
, a new and bigger error message has shown. Above the User Agent: CodeIgniter
:
220 smtp.gmail.com ESMTP g130sm55276890qkb.28 - gsmtp
hello: 250-smtp.gmail.com at your service, [2804:14d:2c81:17a2:f82f:e7e9:68ec:6230]
250-SIZE 35882577
250-8BITMIME
250-AUTH LOGIN PLAIN XOAUTH2 PLAIN-CLIENTTOKEN OAUTHBEARER XOAUTH
250-ENHANCEDSTATUSCODES
250-PIPELINING
250-CHUNKING
250 SMTPUTF8
Failed to authenticate password. Error: 534-5.7.14 Please log in via your web browser and 534-5.7.14 then try again. 534-5.7.14 Learn more at 534 5.7.14 https://support.google.com/mail/answer/78754 g130sm55276890qkb.28 - gsmtp
Unable to send email using PHP SMTP. Your server might not be configured to send mail using this method.