WordPress emails not working

This wasn’t intended to be my first post, but I just finished getting email working for this blog, so I figured why not post how I got it work. We can always do an intro later.

For this blog and another blog I just started, www.playingwithpython.com, I setup a Linux server to host the sites using Apache. After getting the sites setup, I went to setup a couple security plugins that send email alerts. Unfortunately, emails were not working.

Being a fairly recent adopter of Linux, these type of issue are never light bulb moments for me. It takes hitting up Google for the answers. Typically, I scour the web for a couple hours trying pull enough pieces together to get the puzzle put together. This was no different.

In order to save you the time that I wasted, let me just post the steps I did to get this working.

First, I immediately figured I didn’t load sendmail, since I loaded a barebones linux install for this server. So, first step is to load Sendmail.

Install Sendmail:

  1. Since I’m running CentOS, I installed sendmail with “yum install sendmail”.
  2. Next, I set the service to start automatically with the “chkconfig sendmail on” command.
  3. Lastly, start the service with “service sendmail start”.

Alright, send mail is loaded and allows local host by default. Let’s go test these emails again….. nope. Still not working. I was getting the error “Could not instantiate mail function”.

I went to check the logs in the file /var/log/maillog and found the error…

NOQUEUE: SYSERR(apache): can not chdir(/var/spool/clientmqueue/): Permission denied

The problem now is SELinux. You can test and resolve this issue via the following commands:

  1. Check to see if httpd can sendmail by running “getsebool -a | grep mail”
  2. See if “httpd_can_sendmail –> on” shows. If it says off, SELinux is blocking httpd from initiating sendmail.
  3. Run “setsebool -P httpd_can_sendmail on” to fix SELinux.

You should now be able to send emails via WordPress’s, well really PHP’s mail() function.

 

 

Our Blog

How to Perform a Cybersecurity Risk Assessment Like a Pro?

How to Perform a Cybersecurity Risk Assessment Like a Pro?

With cyber attacks increasing by 38% year-over-year according to recent industry reports, businesses can…

Why Cybersecurity Is the Best Investment for Your Small Business?

Why Cybersecurity Is the Best Investment for Your Small Business?

When cybersecurity for small business fails, it’s not just data that gets compromised—entire operations…

Managed IT Services in Pittsburgh: Why Pittsburgh Businesses Trust Local Managed IT Services?

Managed IT Services in Pittsburgh: Why Pittsburgh Businesses Trust Local Managed IT Services?

Managed IT services refer to the outsourcing of your company’s information technology needs to…