'Support of DKIM from Google App Engine PHP for non-Google Workspace email addresses

We are using a mix of hosting services at the moment due to historical reasons:

  • Domain Name: Google
  • Main website (www.ourdomain.com): HostPapa
  • Another website (vm.ourdomain.com): Google App Engine (PHP5)

Both the main site and the other have PHP code sending automated emails. On the main site we use the built-in mail(). On the other site we use Message class of Google App Engine PHP SDK.

I was able to use cPanel of the main site to generate a DKIM public/private key pair. cPanel had me add the DKIM public key under the name of default._domainkey.ourdomain.com. After I did so, emails sent from the main site's PHP appear to be signed correctly.

My question is how to replicate this on Google App Engine? All Google App Engine (PHP5) documentation I found suggests it can be done if the From addresses are part of Google Workspace domain (see Mail API for PHP 5 and Generate a DKIM key for your domain). Unfortunately we cannot do so as our organization firewall blocks all Gmail access from within our network. BTW, this domain is not our organization domain but a separate one operated by just our department.

I don't see any mentioning of DKIM in App Engine PHP SDK's Message class. It seems to be something that has to be configured server-side. I've seen sample code doing client-side DKIM signing with PHPMailer, but also some advices on not to use client-side signing for the underlying sendmail or equivalent service can alter the email header/body and break client-side signatures. But it may be acceptable if it's the only way.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source