Ubuntu – Postfix won’t transfer WordPress contact form emails to the Gmail account

configurationemailpostfixvpsWordpress

In Ubuntu 16.04 VPS with LEMP in DigitalOcean I have a WordPress web site that has a contact form I created with Contact Form 7 (CF7).

My problem

I have a problem transferring emails from my WordPress contact form (CF7) to my email (Gmail).

I must say, I'll humbly prefer a non-plugin solution.

DNS zone for my machine

  1. A record holding the domain.
  2. Cname record holding a www. variant for the domain.
  3. Three NS records to associate DNS requests to my domain, with my IP and the relevant app in its machine.

I did try to add MX records, by the automatic DigitalOcean way of doing so (by clicking Add Gmail MX records button in the DigitalOcean DNS management tool), and 5 MX records were added but I still had the same error after I immediately tried to send a test email from WordPress (see error below).

Currently, the DNS zone has no MX records because I'm not sure they are even required if all I desire in the context of emails is just to send WordPress contact form inquiries to my Gmail account and I'm still in the same state with the same error.

Exact error and debug tries:

I always get the following error message, inside a a red box under the contact form:

Failed to send your message.

Due to this error, nothing is sent anywhere (not even to the Spam folder).

Trying to debug this, I ran the following code to create a log for Postfix:

touch /var/log/mail.log
  • There are no errors in the Nginx logs.

The permissions are:

rw-r--r-- 1 root root

But nothing gets written in this error log after I try to send myself a test email and fail.

Reproducing my problem:

  1. Create a DigitalOcean Ubuntu 16.04 droplet.
  2. Create a LEMP stack and run a WordPress website on it.
  3. sudo apt-get update && sudo apt-get upgrade postfix.
  4. Choose "internet-site" configuration.
  5. Type the domain of the site you work with.
  6. Install Contact Form 7 on your WordPress site and try to send yourself a test email.

My question

What causes this problem?

Maybe I can try something with Postfix or an alternative tool I should use like sSMTP? I'd prefer a minimal to no-conf tool. I emphasize that I don't send any other emails to my Gmail besides those landing in the WordPress contact form, nor do I send no other emails anywhere, from this machine.

In the past, I installed Postfix as described above and there weren't any problems. If you have any idea what to check, what details I should provide, please tell me and I'll edit.


Update

1) The file /etc/postfix/main.cf is all default.

2) Output of ps -efl | grep postfix:

5 S root      4611     1  0  80   0 - 16352 ep_pol 07:42 ?        00:00:00 /usr/lib/postfix/sbin/master -w
4 S postfix   4613  4611  0  80   0 - 16881 ep_pol 07:42 ?        00:00:00 qmgr -l -t unix -u
4 S postfix   4930  4611  0  80   0 - 16869 ep_pol 11:02 ?        00:00:00 pickup -l -t unix -u -c
0 S root      5201  5187  0  80   0 -  3236 pipe_w 12:19 pts/0    00:00:00 grep --color=auto postfix

Best Answer

The problem seems to come from WordPress, form the configuration of the contact form in particular, as the problem also happened with sSMTP which some consider a simpler tool than Postfix:

When I deleted the original form and created a new one, I got a green message saying that the message was sent in a test email.

Here also, I didn't get a message even to the Spam dir, but at least the response was different and the original problem had nothing to do with Postfix.

Related Question