Community Forums
Connect with us on LinkedIn
+ Reply to Thread
Results 1 to 7 of 7
  1. #1
    Member
    Join Date
    Oct 2003
    Posts
    18

    Default Domainkeys not working for PHP scripts

    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:Subjectate: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. #2
    Technical Product Specialist cPanelDavidG's Avatar
    Join Date
    Nov 2006
    Location
    Houston, TX
    Posts
    11,189
    cPanel/Enkompass Access Level

    Root Administrator

    Default

    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. #3
    Member
    Join Date
    Oct 2003
    Posts
    18

    Default

    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. #4
    Technical Product Specialist cPanelDavidG's Avatar
    Join Date
    Nov 2006
    Location
    Houston, TX
    Posts
    11,189
    cPanel/Enkompass Access Level

    Root Administrator

    Default

    Quote Originally Posted by neil_rutherford View Post
    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.
    You may want to switch the app over to use SMTP instead.

  5. #5
    Member
    Join Date
    Aug 2002
    Posts
    1,120

    Default

    Try forcing the envelope-sender using the fifth parameter of PHP's mail() function"

    PHP Code:
    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. #6
    Member
    Join Date
    Oct 2003
    Posts
    18

    Default

    Quote Originally Posted by sparek-3 View Post
    Try forcing the envelope-sender using the fifth parameter of PHP's mail() function"

    PHP Code:
    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?
    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. #7
    Member
    Join Date
    Oct 2003
    Posts
    18

    Default

    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.
    Last edited by neil_rutherford; 07-23-2008 at 03:43 PM.

Similar Threads & Tags
Similar threads

  1. easyapache not so easy? PHP scripts not working
    By Final-Solution in forum cPanel and WHM Discussions
    Replies: 11
    Last Post: 07-07-2008, 11:04 AM
  2. DomainKeys not working
    By blkjck in forum E-mail Discussions
    Replies: 4
    Last Post: 01-22-2008, 04:22 PM
  3. CGI scripts not sending email, php scripts will
    By BianchiDude in forum cPanel and WHM Discussions
    Replies: 1
    Last Post: 11-17-2006, 04:20 AM
  4. Fantastico not working: PHP not working in cPanel/WHM
    By softwareguy in forum cPanel and WHM Discussions
    Replies: 7
    Last Post: 05-25-2006, 02:38 AM
  5. /scripts/runweblogs not working? try /scripts/fixwebalizer
    By MediaHound in forum cPanel and WHM Discussions
    Replies: 0
    Last Post: 03-28-2005, 10:43 AM
Linkedin       Facebook       Twitter       RSS       Flickr       YouTube