Go Back   HowtoForge Forums | HowtoForge - Linux Howtos and Tutorials > Linux Forums > Programming/Scripts

Do you like HowtoForge? Please consider supporting us by becoming a subscriber.
Reply
 
Thread Tools Display Modes
  #1  
Old 15th January 2009, 21:11
gabosdenes gabosdenes is offline
Junior Member
 
Join Date: Dec 2008
Posts: 7
Thanks: 0
Thanked 0 Times in 0 Posts
Default sign mails with php mail() Domainkeys

Hi,I configured my mail server to sign outgoing emails with domainkeys, but I don't know how to sign mails sent with php mail()
I'm using ubuntu server with postfix.
Any ideas?

Denes
Reply With Quote
Sponsored Links
  #2  
Old 16th January 2009, 13:37
falko falko is offline
Super Moderator
 
Join Date: Apr 2005
Location: Lüneburg, Germany
Posts: 41,701
Thanks: 1,900
Thanked 2,741 Times in 2,575 Posts
Default

Try something like this:

PHP Code:
$headers .= "DomainKey-Signature: a=rsa-sha1; s=mail; d=mydomain.com; h=From; q=dns; c=simple; b=$dkey;\n";

$success mail$to $subject $body $headers ); 
__________________
Falko
--
Download the ISPConfig 3 Manual! | Check out the ISPConfig 3 Billing Module!

FB: http://www.facebook.com/howtoforge

nginx-Webhosting: Timme Hosting | Follow me on:
Reply With Quote
  #3  
Old 16th January 2009, 21:32
gabosdenes gabosdenes is offline
Junior Member
 
Join Date: Dec 2008
Posts: 7
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Where the $dkey should be the signature, right? But how do I get the signature?

Denes
Reply With Quote
  #4  
Old 17th January 2009, 12:29
falko falko is offline
Super Moderator
 
Join Date: Apr 2005
Location: Lüneburg, Germany
Posts: 41,701
Thanks: 1,900
Thanked 2,741 Times in 2,575 Posts
Default

I think this could be the contents of your public key.
__________________
Falko
--
Download the ISPConfig 3 Manual! | Check out the ISPConfig 3 Billing Module!

FB: http://www.facebook.com/howtoforge

nginx-Webhosting: Timme Hosting | Follow me on:
Reply With Quote
  #5  
Old 17th January 2009, 13:43
gabosdenes gabosdenes is offline
Junior Member
 
Join Date: Dec 2008
Posts: 7
Thanks: 0
Thanked 0 Times in 0 Posts
Default

I don't get it. Souldn't the mail be signed with the key? You just attach it to the header?

Denes
Reply With Quote
  #6  
Old 18th January 2009, 11:59
falko falko is offline
Super Moderator
 
Join Date: Apr 2005
Location: Lüneburg, Germany
Posts: 41,701
Thanks: 1,900
Thanked 2,741 Times in 2,575 Posts
Default

I'm not sure, I haven't tried this yet...
__________________
Falko
--
Download the ISPConfig 3 Manual! | Check out the ISPConfig 3 Billing Module!

FB: http://www.facebook.com/howtoforge

nginx-Webhosting: Timme Hosting | Follow me on:
Reply With Quote
  #7  
Old 18th January 2009, 13:55
gabosdenes gabosdenes is offline
Junior Member
 
Join Date: Dec 2008
Posts: 7
Thanks: 0
Thanked 0 Times in 0 Posts
Default

falco, no offence but what was the point in responding to a thread when you have no idea what your're talking about?
Reply With Quote
  #8  
Old 19th January 2009, 09:48
topdog topdog is offline
Senior Member
 
Join Date: Jan 2008
Location: South Africa
Posts: 1,352
Thanks: 0
Thanked 153 Times in 150 Posts
Default

There is more to signing than what falko is offering, what happens with domain keys is actually a cryptographic procedure, you have two keys the public and private key, the mail gets signed using a private key, and the recipient then verifies the email using the public key in DNS.

The header that is added is a values obtained by signing the email message
Code:
openssl dgst -sign rsa.private -sha1 <input.file
The problem is this value will be incorrect as the email has not been handed to the MTA yet, the MTA could modify the format of the email meaning all your emails will be rejected at the destination as the verification will fail due to modification by the MTA.

There are option two options i recommend

1. Point PHP to use an MTA and let the MTA do the signing
2. Use a PHP class that uses SMTP instead of using the mail command.

Take a read at the RFC's if you want to get more clued up on it.

http://tools.ietf.org/html/rfc4870 (Domainkeys)
http://tools.ietf.org/html/rfc4871 (DKIM)
__________________
----
http://www.topdog.za.net - Got Linux problems ? - I can help.
http://www.baruwa.org - Try it.
Reply With Quote
  #9  
Old 19th January 2009, 13:13
falko falko is offline
Super Moderator
 
Join Date: Apr 2005
Location: Lüneburg, Germany
Posts: 41,701
Thanks: 1,900
Thanked 2,741 Times in 2,575 Posts
 
Default

Quote:
Originally Posted by gabosdenes View Post
falco, no offence but what was the point in responding to a thread when you have no idea what your're talking about?
I haven't tried PHP's mail() function with DomainKeys, but I've found the contents from my first post in this thread (#2) on another site. That's why I tried to help - not sure if this is a bad thing. Of course, I could've left your post unanswered, but I think that would've left you more frustrated. I'm just trying to be nice...
__________________
Falko
--
Download the ISPConfig 3 Manual! | Check out the ISPConfig 3 Billing Module!

FB: http://www.facebook.com/howtoforge

nginx-Webhosting: Timme Hosting | Follow me on:
Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
procmail can't write Hellbound General 27 8th June 2009 21:51
Postfix & mail forwarding loop varnik Server Operation 21 9th December 2008 15:13
Really Simple DNS Question andysm849 Server Operation 4 20th October 2008 23:32
ISPConfig virtual web pages not working mike_phi Installation/Configuration 8 7th May 2008 16:51
How to send mails using php mail function outside domain pankaj Technical 1 19th December 2005 22:09


All times are GMT +2. The time now is 22:47.


Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2014, vBulletin Solutions, Inc.