I’ve been dealing with some clients at Domainfactory who have, what feels like, been in the process of moving their email to Microsoft 365 and their websites to a shared GoDaddy platform forever. Every time a client finally gets around to it, I have to tweak the SMTP configuration in MODX just to keep FormIt forms sending.
On the old platform, sending via localhost wasn’t allowed. On the new GoDaddy platform, it’s the opposite: SMTP is blocked, and sending via localhost is enforced. Sending through Microsoft 365 is only possible if you enable SMTP on the mailbox and disable two-factor authentication – which is far from ideal.
These restrictions have become increasingly frustrating, especially when the email hosting is on a different provider (e.g., GoDaddy/Domainfactory webserver, IONOS mail server). SPF records alone often aren’t enough, and spam filters become a recurring problem.
To solve this, I developed a solution that allows you to replace the FormIt hooks email
and FormItAutoResponder
with hooks that communicate with an external API handling the mail delivery. This effectively tunnels around the hosting provider’s restrictions, letting you send emails directly via SMTP through your external mail provider.
The function also generates an automatic plain-text version of the email message, which significantly improves spam scores. The hooks are mostly compatible with the original FormIt hooks – in most cases, you only need to swap them out. The mail API consists of a PHP script and PHPMailer and should be installed on a webspace without restrictions, ideally at the same provider as the mail server.
Hopefully, this solution can be useful for others facing similar issues.
The code and documentation are available here:
weitblick/MODX-FormIt-SMTP-API: A secure email and auto-responder integration for MODX FormIt that delegates mail delivery to a separate API server running sendmail.php with PHPMailer. This setup makes it possible to send FormIt emails directly via a dedicated SMTP server, bypassing restrictions or limitations of the hosting provider. - Codeberg.org