library/core/class.email.php
public function To($RecipientEmail, $RecipientName = '') {

      if (is_string($RecipientEmail)) {
         if (strpos($RecipientEmail, ',') > 0) {
            $RecipientEmail = explode(',', $RecipientEmail);
            // trim no need, PhpMailer::AddAnAddress() will do it
            return $this->To($RecipientEmail, $RecipientName);
         }
         if ($this->PhpMailer->SingleTo) return $this->AddTo($RecipientEmail, $RecipientName);
         if (!$this->_IsToSet){
            $this->_IsToSet = TRUE;
            $this->AddTo($RecipientEmail, $RecipientName);
         } else
            $this->Cc($RecipientEmail, $RecipientName);
         return $this;
         
      } elseif ((is_object($RecipientEmail) && property_exists($RecipientEmail, 'Email'))
         || (is_array($RecipientEmail) && isset($RecipientEmail['Email']))) {
         
         $User = $RecipientEmail;
         $RecipientName = GetValue('Name', $User);
         $RecipientEmail = GetValue('Email', $User);
         $UserID = GetValue('UserID', $User, FALSE);
         
         if ($UserID !== FALSE) {
            // Check to make sure the user can receive email.
            if (!Gdn::UserModel()->CheckPermission($UserID, 'Garden.Email.View')) {
               $this->Skipped[] = $User;
               
               return $this;
            }
         }
         
         return $this->To($RecipientEmail, $RecipientName);
      
      } elseif ($RecipientEmail instanceof Gdn_DataSet) {
         foreach($RecipientEmail->ResultObject() as $Object) $this->To($Object);
         return $this;
        
      } elseif (is_array($RecipientEmail)) {
         $Count = count($RecipientEmail);
         if (!is_array($RecipientName)) $RecipientName = array_fill(0, $Count, '');
         if ($Count == count($RecipientName)) {
            $RecipientEmail = array_combine($RecipientEmail, $RecipientName);
            foreach($RecipientEmail as $Email => $Name) $this->To($Email, $Name);
         } else
            trigger_error(ErrorMessage('Size of arrays do not match', 'Email', 'To'), E_USER_ERROR);
         
         return $this;
      }
      
      trigger_error(ErrorMessage('Incorrect first parameter ('.GetType($RecipientEmail).') passed to function.', 'Email', 'To'), E_USER_ERROR);
   }
public function To($RecipientEmail, $RecipientName = '') {

      if (is_string($RecipientEmail)) {
         if (strpos($RecipientEmail, ',') > 0) {
            $RecipientEmail = explode(',', $RecipientEmail);
            // trim no need, PhpMailer::AddAnAddress() will do it
            return $this->To($RecipientEmail, $RecipientName);
         }
         if ($this->PhpMailer->SingleTo) return $this->AddTo($RecipientEmail, $RecipientName);
         if (!$this->_IsToSet){
            $this->_IsToSet = TRUE;
            $this->AddTo($RecipientEmail, $RecipientName);
         } else
            $this->Cc($RecipientEmail, $RecipientName);
         return $this;
         
      } elseif ((is_object($RecipientEmail) && property_exists($RecipientEmail, 'Email'))
         || (is_array($RecipientEmail) && isset($RecipientEmail['Email']))) {
         
         $User = $RecipientEmail;
         $RecipientName = GetValue('Name', $User);
         $RecipientEmail = GetValue('Email', $User);
         $UserID = GetValue('UserID', $User, FALSE);
         
         if ($UserID !== FALSE) {
            // Check to make sure the user can receive email.
            if (!Gdn::UserModel()->CheckPermission($UserID, 'Garden.Email.View')) {
               $this->Skipped[] = $User;
               
               return $this;
            }
         }
         
         return $this->To($RecipientEmail, $RecipientName);
      
      } elseif ($RecipientEmail instanceof Gdn_DataSet) {
         foreach($RecipientEmail->ResultObject() as $Object) $this->To($Object);
         return $this;
        
      } elseif (is_array($RecipientEmail)) {
         $Count = count($RecipientEmail);
         if (!is_array($RecipientName)) $RecipientName = array_fill(0, $Count, '');
         if ($Count == count($RecipientName)) {
            $RecipientEmail = array_combine($RecipientEmail, $RecipientName);
            foreach($RecipientEmail as $Email => $Name) $this->To($Email, $Name);
         } else
            trigger_error(ErrorMessage('Size of arrays do not match', 'Email', 'To'), E_USER_ERROR);
         
         return $this;
      }
      
      trigger_error(ErrorMessage('Incorrect first parameter ('.GetType($RecipientEmail).') passed to function.', 'Email', 'To'), E_USER_ERROR);
   }
public function To ( $ RecipientEmail , $ RecipientName = '' ) { if ( is_string ( $ RecipientEmail ) ) { if ( strpos ( $ RecipientEmail , ',' ) > 0 ) { $ RecipientEmail = explode ( ',' , $ RecipientEmail ) ; // trim no need, PhpMailer::AddAnAddress() will do it return $ this -> To ( $ RecipientEmail , $ RecipientName ) ; } if ( $ this -> PhpMailer -> SingleTo ) return $ this -> AddTo ( $ RecipientEmail , $ RecipientName ) ; if ( ! $ this -> _IsToSet ) { $ this -> _IsToSet = TRUE ; $ this -> AddTo ( $ RecipientEmail , $ RecipientName ) ; } else $ this -> Cc ( $ RecipientEmail , $ RecipientName ) ; return $ this ; } elseif ( ( is_object ( $ RecipientEmail ) && property_exists ( $ RecipientEmail , 'Email' ) ) || ( is_array ( $ RecipientEmail ) && isset ( $ RecipientEmail [ 'Email' ] ) ) ) { $ User = $ RecipientEmail ; $ RecipientName = GetValue ( 'Name' , $ User ) ; $ RecipientEmail = GetValue ( 'Email' , $ User ) ; $ UserID = GetValue ( 'UserID' , $ User , FALSE ) ; if ( $ UserID !== FALSE ) { // Check to make sure the user can receive email. if ( ! Gdn :: UserModel ( ) -> CheckPermission ( $ UserID , 'Garden.Email.View' ) ) { $ this -> Skipped [ ] = $ User ; return $ this ; } } return $ this -> To ( $ RecipientEmail , $ RecipientName ) ; } elseif ( $ RecipientEmail instanceof Gdn_DataSet ) { foreach ( $ RecipientEmail -> ResultObject ( ) as $ Object ) $ this -> To ( $ Object ) ; return $ this ; } elseif ( is_array ( $ RecipientEmail ) ) { $ Count = count ( $ RecipientEmail ) ; if ( ! is_array ( $ RecipientName ) ) $ RecipientName = array_fill ( 0 , $ Count , '' ) ; if ( $ Count == count ( $ RecipientName ) ) { $ RecipientEmail = array_combine ( $ RecipientEmail , $ RecipientName ) ; foreach ( $ RecipientEmail as $ Email => $ Name ) $ this -> To ( $ Email , $ Name ) ; } else trigger_error ( ErrorMessage ( 'Size of arrays do not match' , 'Email' , 'To' ) , E_USER_ERROR ) ; return $ this ; } trigger_error ( ErrorMessage ( 'Incorrect first parameter (' . GetType ( $ RecipientEmail ) . ') passed to function.' , 'Email' , 'To' ) , E_USER_ERROR ) ; }
Adds to the "To" recipient collection.

@param mixed $RecipientEmail An email (or array of emails) to add to the "To" recipient collection.
@param string $RecipientName The recipient name associated with $RecipientEmail. If $RecipientEmail is
an array of email addresses, this value will be ignored.
Adds to the To recipient collection .