Skip to main content

DKIM in cPanel with PHPmailer clarification

Comments

5 comments

  • cPanelMichael
    Hello, If you use a PHP script, you should manually add the DKIM signature to the message headers. Some examples of this are discussed at: Setting up DomainKeys/DKIM in a PHP-based SMTP client The actual keys are stored for each domain name in the following directory: /var/cpanel/domain_keys/private/ Thank you.
    0
  • martin MHC
    Thanks for the feedback, Michael. I have a query for this -- my PHP script (quite rightly) does not have access to this folder, so the script can not send out authorised DKIM mails [class uses file_get_contents function on the key file when sending mail). The obvious solution would be to copy/paste the key file into the account area, however I'm wary of the [obvious] risks of doing that (not least key leakage but also that if the cpanel key gets updated in the future then I'd need to manually update the account-copy of said key). Can you give me a pointer as to the safest (non-duplication?) way to share the keyfile with PHP. Many thanks.
    0
  • cPanelMichael
    Have you tried setting up a PHP test script without the call to the private DKIM key location? Exim should automatically detect the DKIM key path when sending via PHP using SMTP Authentication on the cPanel server: Authentication - Documentation - cPanel Documentation Thank you.
    0
  • martin MHC
    Hi Michael, thanks for the feedback. I have come to a conclusion that PHP DKIM references are only required when using a mailer that is on *another* server, such as people who send PHP emails via gmail.com etc or have seperate data- and email- servers. I think that DKIM is handled entirely above the PHP level when it's all on the same server. Tests show that with all emails sent DKIM and SPF checks are both passed. So; As my whole system is within WHM, do I need to add DKIM details to PHPMailer class? -- NO. If your mailer server is the same server as the DKIM details are setup on then you do not need to add any DKIM details to the PHPMailer class, this is all handled outside of PHP -by the same authenticated server- before email launch. Cheers
    0
  • cPanelMichael
    Hello, I'm happy to see the email passed both DKIM and SPF tests. Thank you for testing it out and updating us with the outcome.
    0

Please sign in to leave a comment.