Part of the EllisLab Network
   
2 of 2
2
Bug with Email Class: Undefined Subject, although it’s sent!!!
Posted: 23 May 2010 03:44 PM   [ Ignore ]   [ # 16 ]  
Grad Student
Avatar
Rank
Total Posts:  32
Joined  03-07-2007

Ran into the same issue.

There is a bug in CI_Email class::_write_headers().

This only happens, if
you are using the ‘mail’ protocol
AND are using the bcc_batch_mode
AND are sending the mail to more than the number of recipients defined in ‘bcc_batch_size’

=> this causes _write_headers() be called more than once and in the second round it tries to access the ‘Subject’ index it has unset in the first round.


To fix this, the following statement:

if ($this->protocol == 'mail')
{
    $this
->_subject $this->_headers['Subject'];
    unset(
$this->_headers['Subject']);

should be this:

if ($this->protocol == 'mail')
{
    
if (array_key_exists('Subject'$this->_headers))
    
{
        $this
->_subject $this->_headers['Subject'];
        unset(
$this->_headers['Subject']);
    
}


Here the complete fixed method (in system\libraries\Email.php)

/**
 * Write Headers as a string
 *
 * @access    private
 * @return    void
 */
function _write_headers()
{
    
if ($this->protocol == 'mail')
    
{
        
if (array_key_exists('Subject'$this->_headers))
        
{
            $this
->_subject $this->_headers['Subject'];
            unset(
$this->_headers['Subject']);
        
}
    }

    reset
($this->_headers);
    
$this->_header_str "";

    foreach(
$this->_headers as $key => $val)
    
{
        $val 
trim($val);

        if (
$val != "")
        
{
            $this
->_header_str .= $key.": ".$val.$this->newline;
        
}
    }

    
if ($this->_get_protocol() == 'mail')
    
{
        $this
->_header_str rtrim($this->_header_str);
    
}

Any comments?

Profile
 
 
Posted: 27 August 2010 09:42 AM   [ Ignore ]   [ # 17 ]  
Summer Student
Total Posts:  5
Joined  03-09-2010

I get this problem to however it’s with SMTP:

A PHP Error was encountered
Severity: Notice
Message: Undefined index: From
Filename: libraries/Email.php
Line Number: 921

Severity: Notice
Message: Undefined index: Return-Path
Filename: libraries/Email.php
Line Number: 570

Any suggestions how to solve it? The email is in fact sent. I just get the error anyhow.

Profile
 
 
   
2 of 2
2