This project is a wrapper of PHP-DKIM library as a component for usage in conjunction with Yii framework. Nothing new, just convenient.
You can always download the latest version from the extensions's GitHub repository.
While DKIM relies on cryptographic signatures, it is quite easy to configure but it requires the use of OpenSSL on the command line (from your web server or on any platform).
openssl genrsa -out key.priv 384openssl rsa -in key.priv -out key.pub -pubout -outform PEMI prefer to keep dkim configuration in separate config/dkim.php file as it includes big chunks of text (RSA keys) that don't look pretty in main config:
// ... 'components' => array( // ... 'dkim' => include(dirname(__FILE__) . DIRECTORY_SEPARATOR . 'dkim.php'), // ... )
And here is config/dkim.php file:
return array( 'class' => 'ext.dkim.Dkim', 'open_SSL_pub' => '...', // Here comes public RSA key 'open_SSL_priv' => '...', // Enter private RSA key here 'domain' => 'domain.com', // Your domain 'selector' => '...' // DKIM record selector );
The basic PHP-DKIM usage for an HTML e-mail is:
$sender = 'john@example.com'; $headers = "From: \"Fresh DKIM Manager\" <$sender>>\r\n". "To: $to\r\n". "Reply-To: $sender\r\n". "Content-Type: text/html\r\n". "MIME-Version: 1.0"; $headers = Yii::app()->dkim->add($headers,$subject,$body) . $headers; $result = mail($to,$subject,$body,$headers,"-f $sender");
The core function is add() which generates the DKIM-Signature: heading (which must preceede the other headers)).
Total 1 comment
You can generate private / public keys with phpseclib, a pure PHP RSA implementation, and if you're willing to modify php-dkim you can eliminate the openssl requirement from that as well, using the same. ie. instead of "openssl_sign($s, $signature, $open_SSL_priv)" you'd do this:
Among other advantages phpseclib confers is portability and a much greater support of key formats.
Leave a comment
Please login to leave your comment.