• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
codeigniter email error: "Undefined index: Subject Filename: libraries/Email.php Line Number: 969"

I cannot work out why I'm getting the error when attempting to send an email:

Quote:A PHP Error was encountered

Severity: Notice

Message: Undefined index: Subject

Filename: libraries/Email.php

Line Number: 969

if($query = $this->member_contact->client_email($client_id)){
                        $client_email = $query['Username'];
                    if($query2 = $this->member_contact->customer_email($customer_id)){
                        $customer_email = $query2['Username'];

                    //SEND EMAIL
                    if($customer_email !== NULL && $client_email !== NULL){
                        $config = Array();
                        $config['mailtype'] = "html";
                        $to = $client_email;
                        $name = 'NAME TEST HERE';
                        $email = $customer_email;
                        $message = "Lorem ipsum dolor sit amet";        
                        $this->email->from($email, $name);
                        $this->email->subject('SUBJECT TEST');



And where did you place this code in a controller library etc?

[quote author="InsiteFX" date="1329637195"]And where did you place this code in a controller library etc?

Yes its a in the controller folder. Is it a bug because I've read other posts with this error and no one has a solution?

Well I just tried it using SMTP on my system with CI 2.1.0 and it worked fine!

public function send_emails()

    $config['protocol']        = 'smtp';
    $config['smtp_host']       = 'smtp_host';
    $config['smtp_user']       = 'user_name';
    $config['smtp_pass']       = 'your_pass';
    $config['smtp_port']       = 25;
    $config['smtp_timeout']    = 5;

    $config['charset']  = 'utf-8';
    $config['crlf']     = "\r\n";
    $config['newline']  = "\r\n";
    $config['wordwrap'] = TRUE;


    $this->email->from('[email protected]_domain.com', 'your_name');
    $this->email->to('[email protected]');

    $this->email->subject('Email Test');
    $this->email->message('Testing the email class.');


    echo $this->email->print_debugger();

No errors at all sending SMTP like this...

Make sure you set the crlf and newline!

And here was my response
220 omta17.westchester.pa.mail.comcast.net comcast ESMTP server ready

hello: 250-omta17.westchester.pa.mail.comcast.net hello [IP address], pleased to meet you
250-SIZE 15728640
250 OK

from: 250 2.1.0  sender ok

to: 250 2.1.5  recipient ok

data: 354 enter mail, end with "." on a line by itself

250 2.0.0 brM91i00B55VgMP3drM9dA mail accepted for delivery

quit: 221 2.0.0 omta17.westchester.pa.mail.comcast.net comcast closing connection

Your message has been successfully sent using the following protocol: smtp

User-Agent: CodeIgniter
Date: Sun, 19 Feb 2012 10:21:07 -0500
From: "me"
To: [email protected]
Subject: =?utf-8?Q?Email_Test?=
Reply-To: "[email protected]"
X-Sender: [email protected]
X-Mailer: CodeIgniter
X-Priority: 3 (Normal)
Message-ID: <[email protected]>
Mime-Version: 1.0

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

Testing the email class.

// change to not show emails etc...

Thanks for the help. It was many problems rolled into one. The first one being that it doesnt work on port 25 for some reason. Luckily my host had an alternative port I could use. This is what worked for me:

function send_email($customer_email, $client_email, $comment_string){
  if($customer_email !== NULL && $client_email !== NULL){

   $message = "<p>Lorem ipsum dolor sit amet<br /> ".$comment_string."</p>";

   $config = Array(
    'protocol' => 'smtp',
    'smtp_host' => 'smtp.strato.com',
    'smtp_port' => 587,
    'smtp_user' => 'my email username',
    'smtp_pass' => 'MY EMAIL PASSWORD',
    'mailtype'  => 'html',
    'charset'   => 'utf-8'
   $this->load->library('email', $config);

   $this->email->from('my email username', 'NAME TEST');

   $this->email->subject('SUBJECT HERE');

   if ($this->email->send()) {
    return true;
   }else {

Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  

  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2020 MyBB Group.