public function setHeaders(Swift_Mime_HeaderSet $headers)
{
if (!$this->_peclLoaded) {
return parent::setHeaders($headers);
}
//dkim_sign(privateKey, selector, domain[, header_canon[, body_canon[, sign_alg[, body_length]]]])
$bodyLen = $this->_bodyLen();
if (is_bool($bodyLen)) {
$bodyLen = -1;
}
$hash = $this->_hashAlgorithm == 'rsa-sha1' ? DKIM_SIGN_RSASHA1 : DKIM_SIGN_RSASHA256;
$bodyCanon = $this->_bodyCanon == 'simple' ? DKIM_CANON_SIMPLE : DKIM_CANON_RELAXED;
$headerCanon = $this->_headerCanon == 'simple' ? DKIM_CANON_SIMPLE : DKIM_CANON_RELAXED;
$this->_dkimHandler = dkim_sign($this->_privateKey, $this->_selector, $this->_domainName, $headerCanon, $bodyCanon, $hash, $bodyLen);
$listHeaders = $headers->listAll();
foreach ($listHeaders as $hName) {
// Check if we need to ignore Header
if (!isset($this->_ignoredHeaders[strtolower($hName)])) {
$tmp = $headers->getAll($hName);
if ($headers->has($hName)) {
foreach ($tmp as $header) {
if ($header->getFieldBody() != '') {
dkim_header($this->_dkimHandler, $header->toString());
$this->_signedHeaders[] = $header->getFieldName();
}
}
}
}
}
return $this;
}