addTextHeader() public method

Add a new basic text header with $name and $value.
public addTextHeader ( string $name, string $value = null )
$name string
$value string
示例#1
0
 /**
  * Add the signature to the given Headers
  *
  * @param Swift_Mime_HeaderSet $headers
  * @return Swift_Signers_DKIMSigner
  */
 public function addSignature(Swift_Mime_HeaderSet $headers)
 {
     // Prepare the DKIM-Signature
     $params = array('v' => '1', 'a' => $this->_hashAlgorithm, 'bh' => base64_encode($this->_bodyHash), 'd' => $this->_domainName, 'h' => implode(': ', $this->_signedHeaders), 'i' => $this->_signerIdentity, 's' => $this->_selector);
     if ($this->_bodyCanon != 'simple') {
         $params['c'] = $this->_headerCanon . '/' . $this->_bodyCanon;
     } elseif ($this->_headerCanon != 'simple') {
         $params['c'] = $this->_headerCanon;
     }
     if ($this->_showLen) {
         $params['l'] = $this->_bodyLen;
     }
     if ($this->_signatureTimestamp === true) {
         $params['t'] = time();
         if ($this->_signatureExpiration !== false) {
             $params['x'] = $params['t'] + $this->_signatureExpiration;
         }
     } else {
         if ($this->_signatureTimestamp !== false) {
             $params['t'] = $this->_signatureTimestamp;
         }
         if ($this->_signatureExpiration !== false) {
             $params['x'] = $this->_signatureExpiration;
         }
     }
     if ($this->_debugHeaders) {
         $params['z'] = implode('|', $this->_debugHeadersData);
     }
     $string = '';
     foreach ($params as $k => $v) {
         $string .= $k . '=' . $v . '; ';
     }
     $string = trim($string);
     $headers->addTextHeader('DKIM-Signature', $string);
     // Add the last DKIM-Signature
     $tmp = $headers->getAll('DKIM-Signature');
     $this->_dkimHeader = end($tmp);
     $this->_addHeader(trim($this->_dkimHeader->toString()) . "\r\n b=", true);
     $this->_endOfHeaders();
     if ($this->_debugHeaders) {
         $headers->addTextHeader('X-DebugHash', base64_encode($this->_headerHash));
     }
     $this->_dkimHeader->setValue($string . " b=" . trim(chunk_split(base64_encode($this->_getEncryptedHash()), 73, " ")));
     return $this;
 }
 /**
  * Add the signature to the given Headers.
  *
  * @param Swift_Mime_HeaderSet $headers
  *
  * @return Swift_Signers_DomainKeySigner
  */
 public function addSignature(Swift_Mime_HeaderSet $headers)
 {
     // Prepare the DomainKey-Signature Header
     $params = array('a' => $this->_hashAlgorithm, 'b' => chunk_split(base64_encode($this->_getEncryptedHash()), 73, ' '), 'c' => $this->_canon, 'd' => $this->_domainName, 'h' => implode(': ', $this->_signedHeaders), 'q' => 'dns', 's' => $this->_selector);
     $string = '';
     foreach ($params as $k => $v) {
         $string .= $k . '=' . $v . '; ';
     }
     $string = trim($string);
     $headers->addTextHeader('DomainKey-Signature', $string);
     return $this;
 }