Welcome Guest, Not a member yet? Register   Sign In
Bug with Email Class: Undefined Subject, although it's sent!!!

Hello. I am getting a strange PHP error when using Email Class.

In the email I am sending I have specified the Subject, after sending email arrives with the subject I've specified, yet I am getting this error on the web page when I fire-up the function:

A PHP Error was encountered

Severity: Notice

Message: Undefined index: Subject

Filename: libraries/Email.php

Line Number: 930

Please tell me how can I solve this?

[eluser]Tom Glover[/eluser]
Check your controller file have you set the index, of subject in there, it has to be set otherwise the error will keep appearing, even if it is an empty index ' '.

If you mean by index : $this->email->subject('') .. sure!! I just told, I am receiving the email with the subject! so I have it like this: $this->email->subject($msg_subject) ..

Here is the function I am using : http://paste.mycodenow.com/view/27790c69
I am currently discussing that in IRC #codeigniter.

[eluser]Tom Glover[/eluser]
I'm sorry but i don't no what else it could be, someone else will have a solution though.

[eluser]Colin Williams[/eluser]
// --------------------------------------------------------------------

     * Set Email Subject
     * @access    public
     * @param    string
     * @return    void
    function subject($subject)
        if (strpos($subject, "\r") !== FALSE OR strpos($subject, "\n") !== FALSE)
            $subject = str_replace(array("\r\n", "\r", "\n"), '', $subject);            

        if (strpos($subject, "\t"))
            $subject = str_replace("\t", ' ', $subject);

        $this->_set_header('Subject', trim($subject));

If you don't ever call subject(), then yes, you will probably see an error from line 930. Odd that the class doesn't do a check first (I don't think Subject is a required email header, is it?)

[eluser]Colin Williams[/eluser]
Can you provide code that consistently throws this error in the latest version of CI? I certainly can't reproduce it.

[eluser]Tom Vogt[/eluser]
[quote author="Colin Williams" date="1217826989"]Can you provide code that consistently throws this error in the latest version of CI? I certainly can't reproduce it.[/quote]

function invite() {
        $loc = setlocale(LC_TIME, 'de_DE.UTF-8', '[email protected]', 'de_DE', 'de', 'ge');
        $data = array();
        $data['subject']='Einladung zur Betriebsratssitzung';

        // send the mail
        $config['mailtype'] = 'html';
        $this->email->from('[email protected]', 'OpenBR');

        // send personalize message to all members
        $mems = $this->Members_model->getlist('Betriebsrat'); // get all full members
        if ($this->Globals_model->check('agenda_personal_invite')) {
            // non-personalized
            $message = $this->load->view('email_einladung_allgemein', $data, true); // get the result instead of displaying it
            $recipients = array();
            foreach ($mems as $m) {
            $this->email->send();    // TODO: error handling
        } else {
            // personalized
            // get next agenda/report day
            $cur = $this->Agenda_model->get_current_agenda();
            $next = $this->Agenda_model->get_agenda($cur);

            foreach ($mems as $m) {
                $data['projects']=$this->Projects_model->getoverview(false, $m->member_id, $next->day);
                $message = $this->load->view('email_einladung_persoenlich', $data, true); // get the result instead of displaying it
                $this->email->send(); // TODO: error handling

Hey Colin,
I am hitting the exact same error on the same line (930). To recreate the problem - try sending to a group of 90+ email addresses - that is when I see it happen. The first 30 or so get sent out fine, with the Correct Subject showing, but then not only does the Subject disappear and errors start getting thrown, but also the HTML body gets garbled.

See these two screengrabs, both the same message, both sent in the same batch.

Good HTML Email received: http://i285.photobucket.com/albums/ll64/...ure3-1.jpg

Garbled HTML Email received: http://i285.photobucket.com/albums/ll64/...ure4-1.jpg

"Error" output by CI: http://i285.photobucket.com/albums/ll64/...cture5.jpg

NOTE - if i change the protocol setting in the config from mail to sendmail, the "Subject" problem goes away, however the HTML is still getting garbled

Can you think of a way I can troubleshoot this w/o sending out the messages, and somehow seeing the values CI is trying to use for each block of 20 messages before it sends them to sendmail (any way to see if it's a CI problem or a sendmail problem)?

Just got another clue.

It appears to be related to

I was sending to 90 email addresses and getting the errors described, this was when bcc_batch_size was set to 20. I just changed it to 100 and all 90 messages went out fine.

Can someone from CodeIgniter please look into it and help me understand a fix, or let me know if it'll just have to be logged as a bug and taken care of in the next release?

Theme © iAndrew 2016 - Forum software by © MyBB