public
Created

Add a "Vanity To" option to CodeIgniter's Email Class

  • Download Gist
MY_Email.php
PHP
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47
<?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 */

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.