PHP mail DKIM (DomainKey) authentication

I need to generate a DKIM (DomainKey) authentication key to be able to send authenticated mail to Gmail, Yahoo etc. with PHP's mail function to be able to contact my costumers. Isn't this possible? How do I generate this key and which DNS TXT record do i need to add to my remote server to be able to use it?
154115Asked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Ray PaseurCommented:
I assume you are thoroughly familiar with this?  If not, you might want to be in touch with the dev community.  See the "Deployment" references on that page.
http://www.dkim.org/

In the alternative, have you considered the Sender Policy Framework?  I am not sure, but I think it may be a simpler, more elegant solution, has gained a little more traction than the DKIM idea.

Sad to say, but the authenticity of email was never part of the design of email, and it is likely to take changes in federal law before email becomes as trustworthy as we would like.

Best of luck with your project, ~Ray
0
154115Author Commented:
I'm not familiar with DKIM or SPF. I don't know what to do? I just want to be able to send mail using PHP's mail function and I thought that this might be an option to avoid Gmails spam filter.
0
Ray PaseurCommented:
Looking at the email posted in the other related question, I think the issue is not PHP at all, but the use of a character that Google cannot interpret.  I will look at that a little more and post back as time permits.
0
Newly released Acronis True Image 2019

In announcing the release of the 15th Anniversary Edition of Acronis True Image 2019, the company revealed that its artificial intelligence-based anti-ransomware technology – stopped more than 200,000 ransomware attacks on 150,000 customers last year.

154115Author Commented:
Thank you Ray. Yes maybe its because of the "ø" character. I really don't know what to do.
0
Ray PaseurCommented:
I would contact Google or post in one of their forums.  See this link:
http://www.google.com/support/forum/p/gmail/thread?tid=2acf1541ea4191b9&hl=en

It might have something to do with the ø character, and if that is the case, they would want to know and would want to fix it, especially if you show them that it works correctly with hotmail.

It might also have something to do with the one blacklist that showed up for your IP address, or a combination of these things.  You might also want to change the return address from "no-reply" to something that can actually receive a reply.

The "from" email address fails my validator program - so it does not pass the PHP filter for a valid email address.  I will try sending an email to it from outlook.
http://www.laprbass.com/RAY_email_validation.php?e=noreply@ølbong.dk
<?php // RAY_email_validation.php
error_reporting(E_ALL);



// A FUNCTION TO TEST FOR A VALID EMAIL ADDRESS, RETURN TRUE OR FALSE
function check_valid_email($email)
{

// IF PHP 5.2 OR ABOVE, WE CAN USE THE FILTER
// MAN PAGE: http://us3.php.net/manual/en/intro.filter.php
    if (strnatcmp(phpversion(),'5.2') >= 0)
    {
        if(filter_var($email, FILTER_VALIDATE_EMAIL) === FALSE) return FALSE;
    }
    else
    {
        $regex = '/^[A-Z0-9_-][A-Z0-9._-]*@([A-Z0-9][A-Z0-9-]*\.)+[A-Z\.]{2,6}$/i';
        if (!preg_match($regex, $email)) return FALSE;
    }

    // FILTER or PREG DOES NOT TEST IF THE DOMAIN OF THE EMAIL ADDRESS IS ROUTABLE
    $domain = explode('@', $email);
    if ( checkdnsrr($domain[1],"MX") || checkdnsrr($domain[1],"A") ) return TRUE;

    // EMAIL NOT ROUTABLE
    return FALSE;
}




// DEMONSTRATE THE FUNCTION IN ACTION
$e = '';
if (!empty($_GET["e"]))
{
    $e = $_GET["e"];
    if (check_valid_email($e))
    {
        echo "<br/>VALID: $e \n";
    } else
    {
        echo "<br/>BOGUS: $e \n";
    }
}
// END OF PHP - PUT UP THE FORM
?>
<form method="get">
TEST A STRING FOR A VALID EMAIL ADDRESS:
<input name="e" value="<?php echo $e; ?>" />
<input type="submit" />
</form>

Open in new window

0
Ray PaseurCommented:
Here is what I got when I tried to use noreply@ølbong.dk in an email from GMail.
lbong.png
0
Ray PaseurCommented:
Here is what I got when I tried it from Outlook.  It looks like this is not a valid character for an email address, or at least not able to pass the common validation schemes.
lbong2.png
0
Ray PaseurCommented:
My conclusion after some experimentation is that the use of ø in the domain name or email address is the problem.  I would try to adopt a strategy that did not need that special character.  Best regards, ~Ray
0
jorjCommented:
Take a look here and skip the technical details if they are too advanced for you:
http://www.tai.ro/2010/04/03/postfix-with-dkim-domainkeys-spf-and-sender-id/

Beside the fact that the character you use seems to be invalid you will still need to have some basic email authentication mechanism if you want to deliver emails which won't be marked as spam. In short, you should use SPF for google, Domainkeys for Yahoo, Sender-ID for Hotmail and DKIM for most of the other servers.

Luckily is not a problem on PHP because it uses postfix or sendmail (or other) system application to send emails. However, setting up the correct authentication requires some work on the server, except for SPF which is only a TXT record at your domain. That should make google happy (for valid email addresses).
0
154115Author Commented:
I used the phpmailer script to send the mail instead since I couldn't send it through the server.

http://sourceforge.net/projects/phpmailer/
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
PHP

From novice to tech pro — start learning today.