lib/mail/Mail.php
public function addSubstitution(
        $key,
        $value = null,
        $personalizationIndex = null,
        $personalization = null
    ) {
        $substitution = null;
        if ($key instanceof Substitution) {
            $s = $key;
            $substitution = new Substitution($s->getKey(), $s->getValue());
        } else {
            $substitution = new Substitution($key, $value);
        }
        if ($personalization != null) {
            $personalization->addSubstitution($substitution);
            $this->addPersonalization($personalization);
            return;
        } else {
            if ($this->personalization[0] != null) {
                $this->personalization[0]->addSubstitution($substitution);
            } else if ($this->personalization[$personalizationIndex] != null) {
                $this->personalization[$personalizationIndex]->addSubstitution($substitution);
            } else {
                $personalization = new Personalization();
                $personalization->addSubstitution($substitution);
                if (($personalizationIndex != 0)
                    && ($this->getPersonalizationCount() <= $personalizationIndex)
                ) {
                    $this->personalization[$personalizationIndex] = $personalization;
                } else {
                    $this->addPersonalization($personalization);
                }
            }
            return;
        }
    }
public function addSubstitution(
        $key,
        $value = null,
        $personalizationIndex = null,
        $personalization = null
    ) {
        $substitution = null;
        if ($key instanceof Substitution) {
            $s = $key;
            $substitution = new Substitution($s->getKey(), $s->getValue());
        } else {
            $substitution = new Substitution($key, $value);
        }
        if ($personalization != null) {
            $personalization->addSubstitution($substitution);
            $this->addPersonalization($personalization);
            return;
        } else {
            if ($this->personalization[0] != null) {
                $this->personalization[0]->addSubstitution($substitution);
            } else if ($this->personalization[$personalizationIndex] != null) {
                $this->personalization[$personalizationIndex]->addSubstitution($substitution);
            } else {
                $personalization = new Personalization();
                $personalization->addSubstitution($substitution);
                if (($personalizationIndex != 0)
                    && ($this->getPersonalizationCount() <= $personalizationIndex)
                ) {
                    $this->personalization[$personalizationIndex] = $personalization;
                } else {
                    $this->addPersonalization($personalization);
                }
            }
            return;
        }
    }
public function addSubstitution ( $ key , $ value = null , $ personalizationIndex = null , $ personalization = null ) { $ substitution = null ; if ( $ key instanceof Substitution ) { $ s = $ key ; $ substitution = new Substitution ( $ s -> getKey ( ) , $ s -> getValue ( ) ) ; } else { $ substitution = new Substitution ( $ key , $ value ) ; } if ( $ personalization != null ) { $ personalization -> addSubstitution ( $ substitution ) ; $ this -> addPersonalization ( $ personalization ) ; return ; } else { if ( $ this -> personalization [ 0 ] != null ) { $ this -> personalization [ 0 ] -> addSubstitution ( $ substitution ) ; } else if ( $ this -> personalization [ $ personalizationIndex ] != null ) { $ this -> personalization [ $ personalizationIndex ] -> addSubstitution ( $ substitution ) ; } else { $ personalization = new Personalization ( ) ; $ personalization -> addSubstitution ( $ substitution ) ; if ( ( $ personalizationIndex != 0 ) && ( $ this -> getPersonalizationCount ( ) <= $ personalizationIndex ) ) { $ this -> personalization [ $ personalizationIndex ] = $ personalization ; } else { $ this -> addPersonalization ( $ personalization ) ; } } return ; } }
Add a substitution to a Personalization or Mail object

If you don't provide a Personalization object or index, the
substitution will be global to entire message. Note that
substitutions added to Personalization objects override
global substitutions.

@param string|Substitution $key Key or Substitution object
@param string|null $value Value
@param int|null $personalizationIndex Index into an array of
existing Personalization
objects
@param Personalization|null $personalization A pre-created
Personalization object

@return null
Add a substitution to a Personalization or Mail object