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

#1
[eluser]rjm[/eluser]
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


Code:
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){
                        $this->load->library('email');
                        $config = Array();
                        $config['mailtype'] = "html";
                        
                        $to = $client_email;
                        $name = 'NAME TEST HERE';
                        $email = $customer_email;
                        $message = "Lorem ipsum dolor sit amet";        
                        
                        $this->email->initialize($config);
                        $this->email->from($email, $name);
                        $this->email->to($to);
                        
                        $this->email->subject('SUBJECT TEST');
                        $this->email->message($message);

                        $this->email->send();

                    }

#2
[eluser]InsiteFX[/eluser]
And where did you place this code in a controller library etc?

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

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?

#4
[eluser]InsiteFX[/eluser]
Well I just tried it using SMTP on my system with CI 2.1.0 and it worked fine!

Code:
public function send_emails()
{
    $this->load->library('email');

    $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->initialize($config);

    $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.');

    $this->email->send();

    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
Code:
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-HELP
250-AUTH LOGIN PLAIN
250-SIZE 15728640
250-ENHANCEDSTATUSCODES
250-8BITMIME
250-STARTTLS
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"
Return-Path:
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...

#5
[eluser]rjm[/eluser]
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:

Code:
function send_email($customer_email, $client_email, $comment_string){
  //SEND EMAIL
  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->set_newline("\r\n");

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

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

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


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


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