Monday, April 22, 2019

unable to Send email using codeigniter

I've a registration form and and want to send email to "To Email" and at the same time want to insert user record in db , insertion is successfull but email is not sending using codeigniter here is my code snippet from model and controller resp.
model:




 public function add_user()
{
$data=array(
'username'=>$this->input->post('user_name'),
'first_name' => $this->input->post('fname'),
'last_name' => $this->input->post('lname'),
'email'=>$this->input->post('email_address'),
'password'=>md5($this->input->post('password'))
);


return $this->db->insert('user',$data);
//return $data;
}
and here is controller code:

$this->user_model->add_user();
$this->thank();
$config = Array(
'protocol' => 'smtp',
'smtp_host' => 'ssl://smtp.googlemail.com',

'smtp_port' => 465,
'smtp_user' => 'abc@gmail.com',
'smtp_pass' => '******',
'smtp_timeout' => '4',
'mailtype' => 'text',
'charset' => 'iso-8859-1'
);


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

$this->email->from('mubbashir.azez@gmail.com');
$this->email->to($data['Email']);
$this->email->subject('test subject');
$this->email->message('hello CI');
$this->email->send();
echo $this->email->print_debugger();


here is view code:




  
', '
');?>




print debugger result:



A PHP Error was encountered


Severity: Notice

Message: Undefined variable: data

Filename: controllers/user.php

Line Number: 82

A PHP Error was encountered


Severity: Warning

Message: fgets() [function.fgets]: SSL: The operation completed successfully.

Filename: libraries/Email.php

Line Number: 1869

220 mx.google.com ESMTP ea4sm1055346wib.7 - gsmtp
hello: 250-mx.google.com at your service, [139.190.86.52]

250-SIZE 35882577
250-8BITMIME
250-AUTH LOGIN PLAIN XOAUTH XOAUTH2 PLAIN-CLIENTTOKEN
250-ENHANCEDSTATUSCODES
250 CHUNKING
from: 250 2.1.0 OK ea4sm1055346wib.7 - gsmtp
to: 555 5.5.2 Syntax error. ea4sm1055346wib.7 - gsmtp
The following SMTP error was encountered: 555 5.5.2 Syntax error. ea4sm1055346wib.7 - gsmtp
data: 503 5.5.1 RCPT first. ea4sm1055346wib.7 - gsmtp
The following SMTP error was encountered: 503 5.5.1 RCPT first. ea4sm1055346wib.7 - gsmtp


The following SMTP error was encountered:
Unable to send email using PHP SMTP. Your server might not be configured to send mail using this method.
User-Agent: CodeIgniter
Date: Wed, 12 Feb 2014 03:26:52 +0500
From:
Return-Path:
Subject: =?utf-8?Q?test_subject?=
Reply-To: "mubbashir.azez@gmail.com"
X-Sender: mubbashir.azez@gmail.com

X-Mailer: CodeIgniter
X-Priority: 3 (Normal)
Message-ID: <52faa3ac53dcf@gmail.com>
Mime-Version: 1.0


Content-Type: multipart/alternative; boundary="B_ALT_52faa3ac53dd9"

This is a multi-part message in MIME format.
Your email application may not support this format.


--B_ALT_52faa3ac53dd9
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: 8bit

hello CI


--B_ALT_52faa3ac53dd9
Content-Type: text/html; charset=utf-8

Content-Transfer-Encoding: quoted-printable

hello CI

--B_ALT_52faa3ac53dd9--

No comments:

Post a Comment

plot explanation - Why did Peaches&#39; mom hang on the tree? - Movies &amp; TV

In the middle of the movie Ice Age: Continental Drift Peaches' mom asked Peaches to go to sleep. Then, she hung on the tree. This parti...