Machform PHP mail / sendmail issues on Apache and nginx

no alt text set

So, i decided to give Machform a spin on a project i was working on. Figured it would be quick and easy to get up and running. It was — locally — but when deploying to my sandbox/staging server, i ran into issues with sending notification emails. It was maddening. Spent a couple of days getting everything working as needed and on the same page for all three differing environments.

The first problem occurred when submitting the form: no notification on-page would show up — it just was a blank area. After much futzing around, looking at logs and such, i decided to start from scratch with a new form, using default options to see what happened:

More research: i ran phpinfo on my localhost configuration, the staging/sandbox server, as well as the production server to compare their setups. They looked identical, but further tests i discovered that non-local servers didn’t have sendmail installed. I figured that out by running some PHP code. Use out the gist below, if you’d like to test on your own server.

Here are the things i checked/did while figuring out what was wrong. Also, be sure to restart Apache or nginx after each install to see what fixes the issue. And notice that the terminal commands might be slightly different if you’re running an Apache server vs nginx. This was a point of annoyance for me being that for some reason our staging and production servers weren’t setup identically — something i’ll have to address with the powers that be that originally setup the servers. But that’s neither here nor there for this piece.

After all of this is installed, Machform should be start to be able to send email notifications. Still running into nginx not sending PDFs, but at least it’s not breaking form submissions; emails get sent, but only with attached images, and no PDF with all the data. It’s odd.

Be sure to keep an eye out on the log files, specifically /var/log/mail.log and /var/log/mail.err

I hope this helps! Get in the comments if you have any questions. Or, send me something on Twitter — @CaptMacSparrow.


[Update 2018.08.21] So, after more digging and issues, i realized that the real slowness culprit was with Gmail! In one of the mail logs, i noticed this portion “verify=FAIL” all throughout when attempting to send mail. I hadn’t set a username/password in System Settings -> “Use SMTP Server to Send Emails” option. Silly me.

Suffice it to say, i had to scour through more Google documentation, message boards, etc., but i came up with a solution for going from 1.5-2 minutes to submit form and get email to send, down to under 20 seconds!

Here’s what you need to do:

Google App Password Screen 1
App Password should be an option at the bottom once 2-Step Verification is setup
Google App Password Screen 2
If for a website, use Other and enter your domain name
Google App Password Screen 3
Your new standalone, unique password for the app/website will be here; copy & paste it into your Machform settings.

I hope that helped you out as it did me. So, basically for SEO purposes: this post update should help with a slow Machform submission using a Gmail or G Suite email address via php mail/sendmail. Machform not sending email, this is for you!


If you found this post useful ...

Wondering why you keep seeing lowercased 'i' in my posts? Read -> Why ‘i’ is not capitalized
Namecheap Referral Banner

Leave a Reply


This site uses Akismet to reduce spam. Learn how your comment data is processed.

Notify of