Question

I'm trying to sign emails with DKIM using PHPMailer Class and i can't get it to work.

When i see the headers in my emails on gmail, i find that the class is successfully injecting DKIM in the email header but gmail doesn't even care.

The question is that i've viewed the headers of linkedIn emails and i found out that they are using 2 DKIM headers, DomainKey-Signature & DKIM-Signature.

What's the difference? and is that why Gmail doesn't verify my emails? & do you recommend any alternative & robust classes to sign emails with domain keys on php?

Thanks

Was it helpful?

Solution

Both use Public/Private keys to digitally sign emails. Both use a text file in the sender's DNS server that contain the public key that can be used by the recipient to verify the signature.

Domain Keys was the first version.

DKIM is the updated version.

The difference is how Domain Keys and DKIM sign the messages, and build the header.

Email recipients may implement either of them (or both). The only thing you can do, is sign with both classes, if you want to cover all bases.

Do you want the technical details on the differences between DomainKeys vs DKIM?

--Dave

OTHER TIPS

DKIM support in PHPMailer 5.1 doesn't work correctly out of the box. Here is what I had to do, to get it working:

  1. I applied the fix at this URL: http://sourceforge.net/tracker/index.php?func=detail&aid=2960165&group_id=26031&atid=385707

  2. At line 566, I had to change this:

    // digitally sign with DKIM if enabled
    if ($this->DKIM_domain && $this->DKIM_private) {
      $header_dkim = $this->DKIM_Add($header,$this->Subject,$body);
      $header = str_replace("\r\n","\n",$header_dkim) . $header;
    }
    

...to this:

  // digitally sign with DKIM if enabled
  if ($this->DKIM_domain && $this->DKIM_private) {

    // Hack to add To: header to the headers which are passed to DKIM_Add
            // Note that this only adds the first To: recipient, so it's going to break
            // if you try to send an email to more than one person simultaneously

    $header_temp = $header . $this->LE . 'To: ' . $this->to[0][0];
    $header_dkim = $this->DKIM_Add($header_temp,$this->EncodeHeader($this->SecureHeader($this->Subject)),$body);
    $header = str_replace("\r\n","\n",$header_dkim) . $header;
  }
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top