In our last episode, I determined that the contact form wasn’t working, even on the server that I thought was working. Further investigation, and a several eMails back and forth from Linode tech support yielded the following:
- The problem is not the Contact Form 7, it is with the eMail setup on the server where WordPress is installed. (Well there is a problem with CF7, but we’ll get to that in a minute.)
- Linode has a guide for setting up PostFix (the background eMail program). In general, Linode guides are great for any Linux application, whether you are using Linode or not.
- To cut to the chase, there were several changes that needed to made.
- It looks like PostFix wasn’t completely configured. It was listening on only localhost. To fix this:Update the “inet_interfaces” value to listen on the actual IP address. in the /etc/postfix/main.cf. file Change this:
From: inet_interfaces = loopback-only
To: inet_interfaces = xx.xxx.xxx.xxx, 127.0.0.1
where xxx.xxx.xxx.xxx is the machine’s IP address.
– Restart Postfix
/etc/init.d/postfix restart
– Verify that everything is working fine
netstat -tulpn | grep 25 #Verify listening on port 25
tail -f /var/log/maillog #See the result of sending an eMail.
- It looks like PostFix wasn’t completely configured. It was listening on only localhost. To fix this:Update the “inet_interfaces” value to listen on the actual IP address. in the /etc/postfix/main.cf. file Change this:
- The other piece of the puzzle involved editing the Domain Name nameserver records. These are required for Google to accept eMails for delivery, and involve two addtional entries for the domain name.
- A reverse name lookup record.
- An SPF record.Discussions for both of these items are located at the following links:
https://www.linode.com/docs/networking/dns/setting-reverse-dns
https://www.linode.com/docs/networking/dns/introduction-to-dns-records#spf
- Finally, the Contact Form CF7 plugin has a setting for the “from” address that is used as the sending address. Typically, you want this to be something like customerservice@mydomain.com, but the default Contact Form setting actually allows the user to put in their own email address which is then included in the email generated by the form, so that you can simply reply to the email generated by the form. A more secure option (and the option required by Google), is to have the from address be in your own domain. I just use the same address for both. If you look at the message body field below, you can see that the email address of the person making the inquiry will show up in the body of the message.