The Community Forums

Interact with an entire community of cPanel & WHM users!
  1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Domainkeys not working for PHP scripts

Discussion in 'E-mail Discussions' started by neil_rutherford, Jul 23, 2008.

  1. neil_rutherford

    Joined:
    Oct 8, 2003
    Messages:
    21
    Likes Received:
    2
    Trophy Points:
    3
    Hi,
    Just been testing domainkeys for a domain on cpanel 11.

    For the test, i used the same e-mail address which was created under
    the domain with DomainKeys enabled.

    If i send a mail from via POP/SMTP (eg: mail.mytestdomain.com) from the domain to my yahoo.com e-mail address, the mail header contains:

    Authentication-Results: mta434.mail.re4.yahoo.com from=mytestdomain.com; domainkeys=pass (ok)
    Received: from xxx.xxx.xxx.xxx (EHLO server.url) (xxx.xxx.xxx.xxx)
    by mta434.mail.re4.yahoo.com with SMTP; Wed, 23 Jul 2008 07:40:14 -0700
    DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=default; d=mytestdomain.com;
    h=Received:Message-ID:From:To:Subject:Date:MIME-Version:Content-Type:X-Priority:X-MSMail-Priority:Importance:X-Mailer:X-MimeOLE:X-Antivirus-Scanner:X-AntiAbuse:X-AntiAbuse:X-AntiAbuse:X-AntiAbuse:X-AntiAbuse:X-Source:X-Source-Args:X-Source-Dir;
    b=KEYREMOVED;



    Notice: domainkeys=pass (ok)


    However, if i send a mail using the same e-mail address via a PHP script on the server, the mail header is as follows:

    Authentication-Results: mta111.mail.re4.yahoo.com from=mytestdomain.com; domainkeys=neutral (no sig)

    with no DomainKey-Signature: section

    Why doesn't it work for PHP mail scripts then?
    If you are doing a mailshot from your CMS control panel, then you'll not be
    utilising domainkeys.

    Neil.
     
  2. cPanelDavidG

    cPanelDavidG Technical Product Specialist

    Joined:
    Nov 29, 2006
    Messages:
    11,279
    Likes Received:
    8
    Trophy Points:
    38
    Location:
    Houston, TX
    cPanel Access Level:
    Root Administrator
    Is your PHP script sending mail by establishing a SMTP connection or by some other means (such as the PHP mail() function)? If this is CMS software, it would likely be a setting in the portion of your software that handles email settings.
     
  3. neil_rutherford

    Joined:
    Oct 8, 2003
    Messages:
    21
    Likes Received:
    2
    Trophy Points:
    3
    it's using the inbuilt php mail() function, not via SMTP.

    I'm sure if it uses SMTP, then the signature would be added as i'm using
    SMTP for the same address via my mail client.
     
  4. cPanelDavidG

    cPanelDavidG Technical Product Specialist

    Joined:
    Nov 29, 2006
    Messages:
    11,279
    Likes Received:
    8
    Trophy Points:
    38
    Location:
    Houston, TX
    cPanel Access Level:
    Root Administrator
    You may want to switch the app over to use SMTP instead.
     
  5. sparek-3

    sparek-3 Well-Known Member

    Joined:
    Aug 10, 2002
    Messages:
    1,384
    Likes Received:
    23
    Trophy Points:
    38
    cPanel Access Level:
    Root Administrator
    Try forcing the envelope-sender using the fifth parameter of PHP's mail() function"

    PHP:
    mail("to@address.com","Subject","Message","From: you@yourdomain.com\r\n","-fyou@yourdomain.com");
    I'm not sure how Domainkeys work. I know this would work for SPF implementations. But it may not work for Domainkeys because I believe there is a signing aspect.

    Can you set a Domainkey up for the server's hostname?
     
  6. neil_rutherford

    Joined:
    Oct 8, 2003
    Messages:
    21
    Likes Received:
    2
    Trophy Points:
    3
    I added the -f option and the -f<email> appeared in the header of the email.. however, no key.
    The domainkeys is an option within the cpanel11 control panel with enable and disable options only and i can't configuring anything outside of this.
    I don't have access to the server either.

    It's not so easy to switch to SMTP if the CMS doesn't have this implemented
    and just uses the mail() function.
    What is the reason why the PHP mail() doesn't work? It sends mail via
    the exim mailserver and the key is a DNS entry... why?
     
  7. neil_rutherford

    Joined:
    Oct 8, 2003
    Messages:
    21
    Likes Received:
    2
    Trophy Points:
    3
    Interesting follow up.. did an experiment.

    The site which isn't being signed with domainkeys via mail() function is
    running PHP 4.4.8 as cgi on the same server as another site running
    PHP 5.2.6 as DSO (both are on apache 2.0.63)


    the mail() function in PHP 5.2.6 (DSO) is being signed with the domainkeys.
    the mail() function in PHP 4.8.8 (cgi) is not being signed with the domainkeys.

    didn't have to use -f as it made no difference either way.

    interesting though looking at the headers on both mails....
    the DSO user is nobody:
    "Received: from nobody by server.url with local (Exim 4.69)"
    where as the cgi user is the cpanel user account:
    "Received: from cpaneluseracct by server.url with local (Exim 4.69)"

    I thought it would have been the other way around.
     
    #7 neil_rutherford, Jul 23, 2008
    Last edited: Jul 23, 2008
Loading...

Share This Page