adityadivekar03 / php-mail-domain-signer

Automatically exported from code.google.com/p/php-mail-domain-signer
0 stars 0 forks source link

Problem with Domain Key #2

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
Hi,

I am trying to sign some mails with getDomainKey, but when the email is check 
for example by port25.com, the say:

Result:         fail (bad signature)

But DKIM works perfect.

My code looks like this:

       $mds = new mailDomainSigner(
            $this->config['dkim'][$tmp[1]]['privateKey'],
            $this->config['dkim'][$tmp[1]]['domain'],
            $this->config['dkim'][$tmp[1]]['selector']
        );

        $headers['domainkey'] = $mds->getDomainKey(
            "to:from",
            array(
                $headers['to'],
                $headers['from']
            ),
            implode("\r\n", $body)
        );

        $headers['dkim'] = $mds->getDKIM(
            "from:to:subject",
            array(
                $headers['from'],
                $headers['to'],         
                $headers['subject']
            ),
            implode("\r\n", $body)
        );

Any idea?

Regards and thanks

Original issue reported on code.google.com by mcuad...@gmail.com on 23 May 2012 at 4:28

GoogleCodeExporter commented 8 years ago
Look at http://code.google.com/p/php-mail-domain-signer/wiki/mailDomainSigner 
at section "method getDomainKey"

There is some notes:
NOTE: the $h and $_h arguments must be in right order if to header location 
upper the from header it should ordered like "to:from", don't randomize the 
order for better validating result.

NOTE: if your DNS TXT contained g=, remove it

So, you should remove "g=xxx" parameter in dns txt, and make sure the headers 
is in right order.

This code:
...
"to:from",
array(
  $headers['to'],
  $headers['from']
),
...

Will not works if your mail headers for to and form didn't in right order. 
Example:

THIS WON'T WORK:
headers
-------
From: me@example.com
To: test@example.com
Subject: Test

getDomainKey
------------
...
"to:from",
array(
  $headers['to'],
  $headers['from']
),
...

THIS SHOULD WORK:
headers
-------
From: me@example.com
To: test@example.com
Subject: Test

getDomainKey
------------
...
"from:to",
array(
  $headers['from'],
  $headers['to']
),
...

THE EASIEST WAY
===============
Look at the raw example: 
http://code.google.com/p/php-mail-domain-signer/source/browse/trunk/test_raw.php

It will automatically ordering the headers for your mail :)

Original comment by amaru...@gmail.com on 7 Jan 2013 at 2:48