I just have to call it from a PHP page, so can be either.
the only emails that will be sent from the server is for new members and newsletters. the server won't receive email. am I on the right path?
Main Topics
Browse All TopicsI'm trying to setup DKIM to verify the emails I send.
1) I installed the dkim project [ http://sourceforge.net/pro
2) I setup the public key in DNS and started it up
3) then I installed the perl module Mail::DKIM. I believe that's what I need to sign the emails.
now what? I just want to be able to send emails with PHP without it ending up in the user's spam folder. I think I'm close just not sure what's the last step
This Question has been solved and asker verified All Experts Exchange premium technology solutions are available to subscription members.
Experts Exchange has been collecting answers to technology questions since 1996…3 million and counting! If you have a question, chances are we already have your answer.
If you can't find the exact answer you're looking for, ask our exclusive community of 50,000 experts. You’ll get a personalized answer from a trusted professional.
Thousands of free tech tips, tricks, how-to’s and tutorials are available in our peer reviewed articles section. See for yourself how smart our experts are, no login required.
Access the answers to your technology questions today.
30-day free trial. Register in 60 seconds.
Members of the expert community talk about why the experience at Experts Exchange is different than what you will find anywhere else.

Try it out and discover for yourself.
30-day free trial. Register in 60 seconds.
Join the community of experts here and help other tech pros by answering question in your area of expertise. You can earn FREE access to all Experts Exchange's premium features and resources.
Well, you said you just wanted to not have the e-mails end up in a users spam folder. Whether a message is flagged as spam or not is up to the client. I'm not familiar with the dkim project, and don't know if any mail clients are either, so this may or may not help solve that problem.
Either way, there is an example of how to send a signed message on the Mail::DKIM::Signer documentation page:
http://search.cpan.org/~ja
As you have found out yourself, implementing DKIM is hard. For this reason, very few email senders have implemented it. I tried to do this myself and eventually realized it was going to be too difficult.
That in mind, however, it's worth mentioning that few email recipients verify messages for DKIM signatures. And even with those that do, a lack of DKIM signature is not going to be enough to stick a message in the spam box. If it were, their customers would lose about 90% of their legitimate email, and that's a conservative estimate.
DKIM is a great idea in theory, because not only does it verify the identity of the sender, it also verifies that the entire message, including headers, has arrived without modification. But with header modification still not uncommon through entirely legitimate mechanisms, such as at an ISP relay, then when a DKIM signature actually is present, even a failed authentication is not sufficient cause to a message to be sent to the spam folder.
The point I'm trying to make is that, although DKIM may one day become a standard litmus test on all email messages, that day is still well in the future. When free, open-source DKIM authentication tools are widely available, when ISP's stop modifying headers, and when the majority of senders are finally signing their outgoing messages, that's when you'll want to make sure you're using it too. But when that day arrives, it'll be easy to do, and you won't need to ask the people at EE how to do it.
Getting back to your original problem, it sounds like your ip address has been blacklisted. This is the first thing you need to address. There are a number of free and paid services you can use to monitor whether your sending ip is blacklisted, and provide you with information to contact the list administrators to find out how to get off. If you're on a shared ip, this will be something you'll need to take up with your host provider. When we had a similar situation, we were able to research and find specific details of how and why our ip was blacklisted (one of the other customers on our server sent out a bunch of "phishing" emails - yuck).
Even once you're no longer blacklisted, you'll still want to make sure that people receiving your messages know that they're really from you and not from someone spoofing your domain. For this, use Sender-ID. It's the Microsoft approach to authentication, and while less secure, it's also really easy and most senders have implemented it.
Sender-ID works by publishing a TXT record in your DNS entry. It tells the email handler on your customer's end that "if my domain really sent an email to you, then it would have come from this IP address: xxx.xxx.xxx.xxx." The email handler then checks to see whether the IP address the message originated with matches the address your policy says it should. If not, then the policy will either state "It still might be from me" or "It definitely isn't from me". In the second case, the email will be discarded. In the first case, other rules come into effect as if the Sender-ID policy weren't there.
But the point is that if it really is from you, then the email handler looks up your reputation profile. If your messages routinely get retrieved from spam folders and marked "Not Spam" then you're going to get through. If you messages are routinely marked as "This is Spam" then you won't. And that's the way it should be. If you're sending out good content-filled newsletters that your customers want to receive, then you're going to be just fine.
Here's the definitive guide to implementing Sender-ID:
http://www.microsoft.com/m
Good luck
thanks for the detailed responses. and you're right DKIM is a HUGE pain to setup.
1) I had already setup Sender-ID. all I did was add the following SPF record to say that my IP for my server can send email. that's all I needed, right?
@
TXT
v=spf1 a ?all
2) I'm NOT on a shared IP. I've recently moved to a new server with a new IP and still many users with Hotmail, Yahoo and AOL complain they're not receiving it or it's in their spam folder. so don't think it's the IP. although how can I confirm?
do you still think DKIM won't solve the problem? I read Yahoo supports it, which is why I originally starting trying to set it up.
Here's one resource for checking whether your ip is blacklisted: http://www.mxtoolbox.com/b
There are others though. I found that one in Google with the query "blacklist ip check"
Did you test that your Sender-ID policy passed? The link I gave previously should have helped with that. I can't read a sender id policy record from memory, but if the wizard says it's right I'd trust it.
As for the others, it's tricky to get through to AOL, no matter what you do. I share your frustration on that score. But Yahoo and Hotmail ought to let you through so long as their users aren't marking your emails as spam.
Still, I want to avoid sounding like an authority on this subject, because I'm not. I'm just a fellow webmaster who had to deal with similar issues. I tried the DKIM approach and finally gave up. But our delivery rates went up noticeably when I implemented Sender-ID, which is why I advised you how I did.
And by the way, in case you find the answer on your own without the help of an expert, please be sure to let us know how you did it. It still bothers me that I never succeeded.
thanks MasonWolf for the continued help
1) I checked the blacklists, they all shows as "OK"
2) I sent an email to my gmail account and in the header it shows "Received-SPF: pass (google.com: domain of my_email designates my_server_ip as permitted sender)". so then I think that confirms Sender-ID works
3) my only idea left is to try and get DKIM working. After tons of problems I finally got it installed and setup in DNS without errors. now I think I just need to somehow sign the emails. I don't see how to use Mail::DKIM to do it with perl. and I couldn't find any PHP solutions. any ideas?
I have been putting off this problem for sometime. I would like to once and for all get this solved. I'm sure most webmasters have frustrations with this
use Mail::DKIM::Signer;
# create a signer object
my $dkim = Mail::DKIM::Signer->new(
Algorithm => "rsa-sha1",
Method => "relaxed",
Domain => "example.org",
Selector => "selector1",
KeyFile => "private.key");
);
$dkim->PRINT("To: $to\n");
$dkim->PRINT("From: $from\n");
$dkim->PRINT("Subject: $subject\n");
$dkim->PRINT("$msg\n");
$dkim->CLOSE;
# what is the signature result?
my $signature = $dkim->signature;
my $signature = $dkim->signature, returns a Mail::DKIM::Signature object.
To get a signature string:
my $sig_string = $signature->as_string();
The signature should be prepended to the message to make the resulting message. At the very least, it should precede any headers that were signed.
open(MAIL, "|/usr/sbin/sendmail -t");
print MAIL "$sig_string\nTo: $to\nFrom: $from\nSubject: $subject\n$msg\n";
close(MAIL);
thanks Adam314. I was able to send an email with the signature, but it didn't verify right. I sent an email to an address which verifies DKIM. it sent back:
DKIM Test: permerror (verification error: key DNS reply corrupt)
do you see anything I'm missing? we're so close
--------------------------
Original message:
Date: Mon, 17 Sep 2007 15:36:09 -0700
Message-Id: <200709172236.l8HMa94E0185
DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=mydomain.com; h=to; q=dns/txt; s=dkim; bh=uoq1oCgLlTqpdDX/iUbLy7J
To: autorespond+dkim@dk.elands
From: support@mydomain.com
Subject: Testing ...
This is a test message
Are all of these parameters correct:
my $dkim = Mail::DKIM::Signer->new(
Algorithm => "rsa-sha1",
Method => "relaxed",
Domain => "example.org",
Selector => "selector1",
KeyFile => "private.key");
);
Also, is the info that is PRINTed exactly the same as the info in the message?
$dkim->PRINT("To: $to\n");
$dkim->PRINT("From: $from\n");
$dkim->PRINT("Subject: $subject\n");
$dkim->PRINT("$msg\n");
yes, tripled checked. all parameters are correct. I didn't get any errors sending the email. but the DKIM verifier couldn't validate the email
so I'm guessing either there's something else that needs to go in the header or something else I need to install. the error said "key DNS reply corrupt". so maybe the problem is after it receives the email and sending a command back to us to verify isn't working. what do you think?
Here's my perl script. I tried a different dkim email verifier it came back with: "ERROR: Signed headers don't contain From header". not sure why such a different error than the other verifier. as for the DNS I added the single key to my domain as a TXT record when I installed DKIM like it said. Doesn't it also have to send a command back to the server to verify? If so, am I missing something?
--------------------------
#!/usr/bin/perl
use Mail::DKIM::Signer;
use warnings;
use strict;
##Email vars
my $to="dkim-test\@testing.dk
my $from= "support\@mydomain.org";
my $subject="Testing dkim";
my $msg="This is a test message";
##DKIM Processing
my $dkim = Mail::DKIM::Signer->new(Al
$dkim->PRINT("To: $to\nFrom: $from\nSubject: $subject\n$msg\n");
$dkim->CLOSE;
my $signature = $dkim->signature;
my $sig = $signature->as_string();
##Send Mail
open(MAIL, "|/usr/sbin/sendmail -t");
print MAIL "$sig\nTo: $to\nFrom: $from\nSubject: $subject\n$msg\n";
close(MAIL);
print "done";
The way it works:
Setup (one time):
You create a public/private key.
You put your public key in your DNS entry.
You keep your private key.
When sending:
You use your private key to generate a signature.
You prepend your signature to your e-mail.
You send the e-mail.
When receiving:
Receiver gets the message, and checks for a DKIM signature.
If found, it gets your public key from your DNS record.
Using your public key and signature on the e-mail, it verifies if the From in the e-mail is correct.
What is the output from this (put it just before the Send Mail, after you get the signature):
print "Headers=" . $dkim->headers() . "\n";
print "Originator=" . $dkim->message_originator-
print "Signature=$sig\n";
Business Accounts
Answer for Membership
by: Adam314Posted on 2007-09-17 at 08:29:52ID: 19905713
The Mail::DKIM module is for use in Perl. Do you want to use perl to send the e-mail, or PHP?