PHPMailer::DKIM_HeaderC()publicWP 1.0

Generate a DKIM canonicalization header. Uses the 'relaxed' algorithm from RFC6376 section 3.4.2. Canonicalized headers should always use CRLF, regardless of mailer setting.

Метод класса: PHPMailer{}

Хуков нет.




$PHPMailer = new PHPMailer();
$PHPMailer->DKIM_HeaderC( $signHeader );
$signHeader(строка) (обязательный)


Код PHPMailer::DKIM_HeaderC() WP 6.5.2

public function DKIM_HeaderC($signHeader)
    //Normalize breaks to CRLF (regardless of the mailer)
    $signHeader = static::normalizeBreaks($signHeader, self::CRLF);
    //Unfold header lines
    //Note PCRE \s is too broad a definition of whitespace; RFC5322 defines it as `[ \t]`
    //That means this may break if you do something daft like put vertical tabs in your headers.
    $signHeader = preg_replace('/\r\n[ \t]+/', ' ', $signHeader);
    //Break headers out into an array
    $lines = explode(self::CRLF, $signHeader);
    foreach ($lines as $key => $line) {
        //If the header is missing a :, skip it as it's invalid
        //This is likely to happen because the explode() above will also split
        //on the trailing LE, leaving an empty line
        if (strpos($line, ':') === false) {
        list($heading, $value) = explode(':', $line, 2);
        //Lower-case header name
        $heading = strtolower($heading);
        //Collapse white space within the value, also convert WSP to space
        $value = preg_replace('/[ \t]+/', ' ', $value);
        //RFC6376 is slightly unclear here - it says to delete space at the *end* of each value
        //But then says to delete space before and after the colon.
        //Net result is the same as trimming both ends of the value.
        //By elimination, the same applies to the field name
        $lines[$key] = trim($heading, " \t") . ':' . trim($value, " \t");

    return implode(self::CRLF, $lines);