Created
February 18, 2012 23:13
-
-
Save kevinsmith/1861286 to your computer and use it in GitHub Desktop.
Add a "Vanity To" option to CodeIgniter's Email Class
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed'); | |
class MY_Email extends CI_Email { | |
/** | |
* Set Vanity To address | |
* | |
* The Vanity To address is the address that is shown in the recipient's email | |
* program, not the address to which the email is routed. | |
* | |
* @access public | |
* @param string | |
* @param string | |
* @return void | |
*/ | |
public function vanity_to($to, $name = '') | |
{ | |
if (preg_match( '/\<(.*)\>/', $to, $match)) | |
{ | |
$to = $match['1']; | |
} | |
if ($this->validate) | |
{ | |
$this->validate_email($this->_str_to_array($to)); | |
} | |
if ($name == '') | |
{ | |
$name = $to; | |
} | |
if (strncmp($name, '"', 1) != 0) | |
{ | |
$name = '"'.$name.'"'; | |
} | |
$this->_set_header('To', $name.' <'.$to.'>'); | |
return $this; | |
} | |
} | |
// END MY_Email class | |
/* End of file MY_Email.php */ | |
/* Location: ./application/libraries/MY_Email.php */ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment