PHP mails not working on Cpanel Server

On a cpanel server, PHP scripts can’t sent email. Incoming and outgoing emails for email users (mailbox) are working properly.

To debug, loggged in to SSH as one of the cpanel user.

If SSH access is not enabled, enable SSH in WHM.

Once logged in, verify sendmail works.

I get above error message. This is because permission error with /usr/sbin/sendmail.

To fix, run

If you are using CloudLinux CageFS, try disable and see if it works. If it work after you disable CafeFS, run

Install SourceGuardian in Cpanel Server

To install sourceguardian PHP loaders in Cpanel server, run

Install SSL for Cpanel Server Hostname

Cpanel will provide Free SSL for server hostname if server hostname resolve to servers main IP address and server have valid cpanel license.

Cpanel will check for hostname SSL when upcp runs. This is run once everyday.

You can manually run SSL check by running

If you have a paid SSL, you can install it in

WHM > Service Configuration > Manage Service SSL Certificates


Create New Hosting Account in WHM

To create new hosting account in Cpanel/WHM, login to WHM at


Now to go

You can also use the search box on left top side of WHM. Search for “create”, then click on “Create a New Account” link.

On “Create a New Account” page, you need to enter your domain name. User name will be auto generated. Click “Password Generator” to generate secure password. Make sure you copy this password as you need it later for login to Cpanel/FTP.

Scroll down and click “Create button”.

Now your hosting account is ready.

You will be able to login to Cpanel at


Change PHP version

To change PHP version for a web site, login to cpanel at


Once logged in search “php”

Click on “MultiPHP Manager” button. On next page, you will be able to change PHP version for the web site.

On this page, click the checkbox right side of your domain name. From “PHP Version” drop down, select the PHP version you need. Click Apply. Now your site have selected PHP version.

Amazon Ec2 Fixing Cpanel IP after restore from snapshot

On an Amazon EC2 server running Cpanel, i had to restore from Snapshot as some data was missing. Once restored, i changed Elastic IP to new EC2 instance. But sites did not work. This is because Internal IP of EC2 instance got changed when you restore from snapshot.

In httpd.conf VirtualHosts where using old internal IP But this IP was no longer available in the server, new Internal IP was

Check if sites are still using old internal IP address

To change IP, you need to do the following

WHM >> Home >> Multi Account Functions >> Change Multiple Sites’ IP Addresses

1. Select all the accounts showing for the current ip
2. Select “Change IPs of Selected Accounts”
3. In the New Address dropdown, you would select the External IP for all the accounts
4. Select Change IPs

In Change Multiple Sites’ IP Addresses, drop down listed (Elastic IP Address) and I selected for all sites and is working fine now.

Now rebuild httpd.conf file with

See Cpanel Server Behind NAT (Amazon AWS), Cpanel Server

Cpanel Server Behind NAT (Amazon AWS)

When hosting Cpanel server behind NAT like Amazon AWS, Google Cloud etc.. where you have internal IP and external IP, you need to enable NAT so cpanel will map external IP to internal IP.

First make sure external IP is not added to your server. Now run

On AWS, this generate a file like

Here = internal IP. = external IP.

Now login to WHM, go to Home > IP Functions > IP Migration Wizard

Change your sites IP address with INTERNAL IP address.

Show IP Address Usage will show your external IP address

Home > Server Configuration > Basic WebHost Manager® Setup > Basic Config > The IPv4 address (only one address) to use to set up shared IPv4 virtual hosts. will show your external IP address.

See Cpanel Server, Amazon Ec2 Fixing Cpanel IP after restore from snapshot

Cpanel Server Block Incoming SPF Failed Mails

One of the customer email account as getting too much incoming emails from [email protected]

First i tried to block the sender IP, but they are using too many IP.

To stop this incoming email, i edited


Add below

Restart exim

Now watch the mail log with

Enable DKIM on Cpanel Server

DKIM (DomainKeys Identified Mail) is a way to digitally sign your out going emails. This help prevent spam.

On Cpanel server, you can install for a site, run

If you want to enable DKIM on all sites on a cpanel server, run following as user root.

This will also enable SPF.