Welcome Guest, Not a member yet? Register   Sign In
Email Library Modified
#1

[eluser]Unknown[/eluser]
The email library in code igniter does not have an option to set name in the to address. I have added a code where the names can be passed as an array to the to function as an array with respect to the email address specified in the to parameter of the function.

You can just replace the to function with the below code:

function to($to,$to_name=array())
{
$to = $this->_str_to_array($to);
$to = $this->clean_email($to);

if ($this->validate)
{
$this->validate_email($to);
}
$temp_to = "";
if(is_array($to_name))
{
foreach($to_name as $key => $value)
$temp_to .= $value . "<" . $to[$key] . ">,";
}
if(strlen($temp_to) > 0)
$temp_to = substr($temp_to,0,-1);
else
$temp_to = implode(",", $to);

if ($this->_get_protocol() != 'mail')
{
$this->_set_header('To', $temp_to);
}

switch ($this->_get_protocol())
{
case 'smtp' : $this->_recipients = $temp_to;
break;
case 'sendmail' : $this->_recipients = $temp_to;
break;
case 'mail' : $this->_recipients = $temp_to;
break;
}
}




Theme © iAndrew 2016 - Forum software by © MyBB