PHP function mail() fails dkim

hello team

I have WHMCS configured to send mail with php function with Virtualmin server, I read several topics and forums pro not see your solution to this.

I have properly configured dkim in Virtualmin, dns records are fine, if I send mail from my pc to my server using outlook no problem, dkim appears in the headers.

But if WHMCS send email with php function does not put dkim in the headwaters of the mail. Gmail, hotmail detects it as SPAM.

I hope to be clear. This is what I report if I send mail from WHMCS via php

The Port25 Solutions, Inc. team


Summary of Results

SPF check: neutral DomainKeys check: neutral DKIM check: fail Sender-ID check: neutral SpamAssassin check: ham

DKIM check details:

Result: fail (wrong body hash: expected j0NgX1RpIfzASyfFoCZSNKCeJGkNqjOdo9KPiwDst9M=) ID(s) verified: Canonicalized Headers: To:'20'Alejandro'20'Toriz'20''0D''0A' Subject:'20'New'20'Product'20'Information'0D''0A' Date:'20'Sat,'20'8'20'Jun'20'2013'20'20:23:11'20'-0500'0D''0A' From:'20'""'20''0D''0A' Message-ID:'20''0D''0A' MIME-Version:'20'1.0'0D''0A' Content-Type:'20'multipart/alternative;'0D''0A' '09'boundary="b1_83fc8832fbeb0ed1c707ef197397dad1"'0D''0A' DKIM-Signature:'20'v=1;'20'a=rsa-sha256;'20'c=simple/simple;'20';'0D''0A' '09's=xtrmhost;'20't=1370740991;'0D''0A' '09'bh=Jy2oUvozBHiJ5zAuFtNbjZibdgc042JUa4+tB7nYynM=;'0D''0A' '09'h=To:Subject:Date:From:Message-ID:MIME-Version:Content-Type;'0D''0A' '09'b=



Is PHP sending email via the SMTP server on your system, or directly to a remote mail server?


 PHP is sending through localhost

SMTP = localhost

Yes i sent it...

09/06/2013 20:30 Su Pedido WHMail 10 USA, esta Listo!

Direct and sent by WHMCS

I send another... acliente @ xtrmhost . net

09/06/2013 21:06 New Product Information

Ok, got it. On my system, spamassassin didn't complain about the DKIM header at all.

What are you using to do the DKIM check?


A) If I send it from the server using WHMCS, gmail, hotmail, and do not know how many more point to it as SPAM.

B) However if I send messages from my PC on Microsoft Outlook to Gmail recipients, etc. NO marks them as SPAM.

To this I began to see differences because this silk. And he's only difference is that option A) has no DKIM in Option B) yes.

This probe it with the service you give here to check messages.

Or that another reason that you know that Gmail Hotmail etc generates clearly marked as SPAM, WHMCS outgoing emails.

Could you also send me an email at my gmail address ? The message to my address didn't fail DKIM or get marked as spam.

Ready, I sent you two emails from acliente @ xtrmhost. net from WHMCS

Thanks - oddly gmail doesn't report anything about the DKIM signature on that email, as it seems to have been classified as spam for other reasons (which unfortunately gmail doesn't report).

It would be interesting to try sending a message from WHMCS that just contains "hello world" and see if that gets classified as spam.

Thanks but. even so you can make firm dkim emails sent with php?

Well, it looks like the messages from PHP are being DKIM-signed - but are being rejected as spam for other reasons.


How did you configure Virtualmin to send Outgoing email. I have WHMCS and it does not work. I just need outgoing mail from all domains. All incoming email is hosted on exchange server.

Your help is greatly appreciated. I am no expert so please outline steps.

Thanks in advance.


Are you having problems in addition to DKIM with outgoing email?

Normally, there isn't anything you need to do in order for outgoing email to work -- outgoing email should work without any additional configuration.

looks like postfix or some follow on process is modifying the body of the email after the signature is added.

Try configuring /etc/opendkim.conf to contain:

Canonicalization relaxed/relaxed

and see if the problem remains. After that I'd configure your application to save the email directly to file and compare the contents of that file compared the the email sent.

Hi Jamie,

I need to vent, so apologize upfront for it.

At this point I am so frustrated with Webmin/Virtualmin that I am about to dump it and Pay for Cpanel. My 2 cent feed back. This control panel was designed by a programmer to have a complex UI where nothing is logical and not helpful for a end user.

All I want is out going email to work and nothing works. I cannot find any documentation that shows step by step how to setup everything. Saying it should work is not correct. It does not. So here is what I am asking help for? Postfix documentation is vague and looks like was written by a lazy 2 year old, that did not want to explain the details.

  1. What email server should I use? Has Qmail, Postfix, confusing
  2. How to configure this for just out bound mail for hosted websites.
  3. All email for domain is on Microsoft Exchange server that works great.

There are several websites hosted on this server and none of them are sending any email. There will be no user emails, meaning this machine will not be the email server for users to get inbound emails or send out emails with their email id. Only the website generated emails will need to be send.

Sorry if I sound angry and frustrated. I do not mean to. Let me know what i need to do to get this to work.



Hi Bruno -- we're sorry that you're having trouble getting email to work.

However, it'd be best if you could open a new support request regarding your issue. In that request, let us know what problems you're having, what error messages you're seeing in the email logs, and any other details you feel may be relevant.

Note that when running the script, it configures Postfix for you, which is the email service we recommend. Also, outgoing email should work by default, you shouldn't need to configure anything for that to work -- though if your primary email server is a different service, you may need to disable the "Mail for Domain" feature, which tells Postfix to deliver email locally.

So, open up a new support request, let us know what issues you're seeing and what's in the logs, and we can figure out how to resolve the issues you're seeing.

Thanks for the quick response. I will open a separate ticket.