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

[eluser]ch5i[/eluser]
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:

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

should be this:

Code:
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)

Code:
/**
* 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?


Messages In This Thread
Bug with Email Class: Undefined Subject, although it's sent!!! - by El Forum - 05-23-2010, 01:44 PM



Theme © iAndrew 2016 - Forum software by © MyBB