src/email.php
public static function protect_emailaddress($emailaddress, $catchall_address=null) {
	if (empty($catchall_address)) {
		if (empty(self::$config)) {
			self::load_config();
		}
		
		$catchall_address = self::$config['from'];
	}
	
	$recipient_name = null;
	if (is_array($emailaddress)) {
		$recipient_name = current($emailaddress);
		$emailaddress   = key($emailaddress);
	}
	
	if (self::validate($emailaddress) == false) {
		$exception = bootstrap::get_library('exception');
		throw new $exception('can not convert invalid email address');
	}
	
	
	$emailaddress_key = preg_replace('{[^a-zA-Z0-9_]}', '_', $emailaddress);
	$emailaddress = str_replace('@', '+'.$emailaddress_key.'@', $catchall_address);
	
	if ($recipient_name) {
		$emailaddress = array($emailaddress => $recipient_name);
	}
	
	return $emailaddress;
}
public static function protect_emailaddress($emailaddress, $catchall_address=null) {
	if (empty($catchall_address)) {
		if (empty(self::$config)) {
			self::load_config();
		}
		
		$catchall_address = self::$config['from'];
	}
	
	$recipient_name = null;
	if (is_array($emailaddress)) {
		$recipient_name = current($emailaddress);
		$emailaddress   = key($emailaddress);
	}
	
	if (self::validate($emailaddress) == false) {
		$exception = bootstrap::get_library('exception');
		throw new $exception('can not convert invalid email address');
	}
	
	
	$emailaddress_key = preg_replace('{[^a-zA-Z0-9_]}', '_', $emailaddress);
	$emailaddress = str_replace('@', '+'.$emailaddress_key.'@', $catchall_address);
	
	if ($recipient_name) {
		$emailaddress = array($emailaddress => $recipient_name);
	}
	
	return $emailaddress;
}
public static function protect_emailaddress ( $ emailaddress , $ catchall_address = null ) { if ( empty ( $ catchall_address ) ) { if ( empty ( self :: $ config ) ) { self :: load_config ( ) ; } $ catchall_address = self :: $ config [ 'from' ] ; } $ recipient_name = null ; if ( is_array ( $ emailaddress ) ) { $ recipient_name = current ( $ emailaddress ) ; $ emailaddress = key ( $ emailaddress ) ; } if ( self :: validate ( $ emailaddress ) == false ) { $ exception = bootstrap :: get_library ( 'exception' ) ; throw new $ exception ( 'can not convert invalid email address' ) ; } $ emailaddress_key = preg_replace ( '{[^a-zA-Z0-9_]}' , '_' , $ emailaddress ) ; $ emailaddress = str_replace ( '@' , '+' . $ emailaddress_key . '@' , $ catchall_address ) ; if ( $ recipient_name ) { $ emailaddress = array ( $ emailaddress => $ recipient_name ) ; } return $ emailaddress ; }
protect email addresses from going to real people on non-production environments

it returns the website's sender address with the original one as '+alias'

@param  string $emailaddress     i.e. user@company.com
@param  string $catchall_address i.e. development@project.com
@return string                   i.e. development+user_company_com@project.com
protect email addresses from going to real people on non - production environments