Email Piping: Google Apps

This article covers how to go about configuring your WHMCS installation’s Support Ticketing feature along with Google Apps Hosted Email Service for Domains.

It is assumed that you already have your WHMCS installation set up and working properly on your web server. If so then you are ready to go!

Follow these steps:

1. Create a google app acct for your domain
2. Verify your domain for Google
3. Log into Google Control Panel for your domain and create
appropriate email accounts that will be using WHMCS ticketing
system and receiving tickets.
4. For all accounts that will be receiving tickets, be sure to enable
POP3 and IMAP in Google Mail’s webmail interface.
5. Adjust your mx records on your webserver to redirect your email
service to google.
6. Here’s one of the “gotchas” in getting this set up. You must enable
Imap-SSL/Pop3-SSL with your webserver’s php installation. Many
times you will need to contact your hosting providers to do this for
you. The reason for that is because Google Mail services will only
accept secured connections. (or try install php5-imap package)
7. In WHMCS, in support depts, Create a department and configure
the email account assigned to it like so:
port: 995
user: [email protected]
pwd: yourpassw0rd
8. In the account you set up in WHMCS in support dept, make sure to
go into google settings to enable both IMAP and POP.
9. Set up your cron job within your Web Hosting control panel
(Plesk, cPanel, Direct Admin etc.):
*/5 * * * * php -q /home/username/public_html/whmcs/pipe/pop.php


Easy steps to make Google Apps for Your Domain work with WHMCS


I figured I would share with you how to setup Google Apps to work with WHMCS Support since I figured it out myself. With this way, you can use multiple support departments despite Gmail rewriting the from address. I suggest reading the entire thing over first, then follow each step.

Step 1 – Sign up for Google Apps

A. Visit and sign-up. For those of you in need of a free edition, use this link:…/editions.html

B. Verify your domain by uploading the .html file or adding the cname record

C. Follow the instructions for configuring Google Apps and configuring your DNS. You will need to change and add MX records, add cname records, etc. You should be able to find help at Google if you need it. Note: this will make your old setup no longer work. I am listing this in Step 1 so it gives time to propagate.

Step 2 – Create Email Accounts

A. From within your new Google Apps dashboard, create your email addresses according to your departments (ie. [email protected], [email protected], etc). The passwords can all be the same if the password is strong enough. However, you may want to consider having them all be different.

B. Create another email account such as [email protected], [email protected], [email protected], etc. Use a strong password.

C. Log in to each of the new email accounts to activate them. Enable POP and IMAP while you are logged in.

Step 3 – Support Departments in WHMCS

A. From within WHMCS, create or edit your support departments. Use the following information:

port: 995
user: [email protected]
pwd: yourpassw0rd

Be sure that you have Imap-SSL/Pop3-SSL enabled on your server. Check to see if your server/firewall permits the connection: telnet 995

B. Create the cron job: “*/5 * * * * php -q /home/username/public_html/whmcs/pipe/pop.php” Note: you may want to alter the minutes so that the emails are imported faster than 5 minutes.

Step 4 – SMTP in WHMCS

A. Refer to (easiest thing to do here is download the new files from Note: backup your database and backup the two individual files you will be overwriting. Not responsible for any data loss or issues.

B. Go to Configuration > Mail

Mail Type – SMTP
SMTP Port – 587 (make sure this isn’t blocked on your server/firewall)
SMTP Host – tls://
SMTP Username: enter in that ‘main’ email address you made. (ie. [email protected], [email protected])
SMTP Password: your_strong_password

Step 5 – The Trick

A. This is the part I figured out that makes this possible. It is the key to making this work with multiple departments. Log into your ‘main’ email account (ie. [email protected], [email protected]). Click the “Settings” link in the top right corner. Click the “Accounts” tab. In the “Send mail as:” section, click the “Add another email address you own” link. Enter in the name of the department (ie. Company Support or Company Sales) and enter in the respective email address. Click the “Next” button. Send the verification. Wait until you get a new support ticket in WHMCS. In the new ticket, find the verification code and paste it into the pop box that is open from your Google Apps accounts.

B. Repeat Step 4 A for as many departments as you have

Note: Step 4 will enable you to have multiple support departments and will prevent your email from being marked as spam. Some providers such as Hotmail will show your emails as “From Company on Behalf of Company Support “. I don’t see a workaround for this and it doesn’t really bother me. When they click the “Reply” button, it will reply to the respective department. The only way to totally stop this is to enable SMTP credentials at the department level rather than globally (in whmcs)


How To Run A Sucessfull Server Managment Company

Being a Technical Support Executive is one of the challenging jobs you could ever do, because here you will have to directly interact with the customers of different types and different characters real time. And if it is a remote interaction, it is going to further challenging.

Word ‘challenging’ doesn’t mean that it is difficult, but if you can’t understand what a customer needs, you will end up seeing yourself in a very drastic position.

There are a few rules which should be kept in mind while providing .

1. Trust your customers.

Customer is always right! As a Technical Support person, your prime duty is to trust what your customer says. Never try to prove that he is wrong, but instead prove that you are right. Both may sound similar but in actuality are 2 different things. No one wants to hear that one is wrong and no one in this world would ever say, ‘Yeah !! My idea sucks’. Always tell the customer that you have a better idea and he will surely buy that. But if you say that his idea is wrong, it might result in an unnecessary row and in the end, you lose a customer.

2. Communicate effectively.

Always listen what the customer has to tell. The more you listen, the more you understand his/her issue. I have seen a few Customer representatives starting to explain things before fully listening to a customer. And result? A lot of confusion and might need a lot of follow-ups to sort that. The more time you spend listening to him, the lesser you spend to resolve his/her issues.

3. All are KING customers.

Treat all your customers as KING customers irrespective of how small or large the business they have with you. In my personal experience, we have seen customers grow along with us. The ones who brought in less than 100 dollar a month have grown big enough to pay us thousands of dollars. So never underestimate or predict the potential of a customer.

4. Go an extra mile

Always go an extra mile for the customers because there is no one in this world who doesn’t like that. Assume how happy you will be if you get your car water washed for free after a normal service. I got that done once and hence this example got a place here, couldn’t think of a better one. The ‘extra’ mile that you go brings the customer delight and even brings extra business as well.

5. Educate customers.

Everyone (lazy people excluded) likes to learn new things. By educating a customer, you are doing 2 things.

a) Making sure that the customer understands what the issue is.
b) Making sure that he doesn’t come back again for the same issue (as he already knows how to solve this.

The most important part is the amount of time you will save later if an issue is dealt correctly for the very 1st time.

Installing cPanel & WHM

Installing cPanel & WHM

To install cPanel & WHM, run these commands:

cd /home — Opens the /home directory.
wget -N — Fetches the latest installation files from cPanel’s servers.
sh latest — Opens and executes the installation files.

If licensing fails (due to a strict firewall or modified IP), run the command /usr/local/cpanel/cpkeyclt to activate your cPanel & WHM license.

note Note: During the cPanel & WHM installation process, Apache 2.2 and PHP 5.2.17 are installed by default. After this installation process is complete, you can customize your server’s Apache and PHP configuration with WHM’s EasyApache feature.

How to block IP addresses of certain countries using IPtables

1. First we would need the IP address subnets listed for a particular country. You can get this from websites like:

2. Copy and Paste them into a file called country_IP

3. Now we create the script file called

The contents of which should be as follows :


if [ -f country_IP ]


for IP_select in `cat country_IP`


iptables -A INPUT -s $IP_select -p tcp -j ACCEPT



echo “Can’t read country_IP”


4. To deny the IP ranges from a particular country create a new script file called and change the above highlighted line to:

iptables -A INPUT -s $IP_select -p tcp -j DROP

5. You can add the following option to specify any particular port(example the default SSH port):

–dport 22

The complete command would be like:

iptables -A INPUT -s $IP_select -p tcp –dport 22 -j ACCEPT or

iptables -A INPUT -s $IP_select -p tcp –dport 22 -j DROP

6. Now give the script file sufficient permissions :

chmod 755 or

chmod 755

7. And finally to execute the script :


How to calculate Apache MaxClients value and MySQL memory usage

Theoretically, MaxClients = (Total Memory – Operating System Memory – MySQL memory) / Size Per Apache process.

Assume we have a server with 2GB memory

Total memory: is the available physical RAM in the server. In this case 2GB.

Operating System Memory: Stop Apache and MySQL in the server to calculate the actual memory used by OS (rough figure) using the below command:

ps aux | awk ‘{sum1 +=$4}; END {print sum1}’

In our test VPS:

[email protected] [~]# ps aux | awk ‘{sum1 +=$4}; END {print sum1}’

Then restart Apache and MySQL and wait for a while to get the apt results for Apache and MySQL memory utilization.

Now we will see steps to calculate the MySQL memory utilization:

MySQL memory:

You will come across a lot of calculations for MySQL usage, but the one I found somewhere near was:

mysql_memory= (key_buffer_size + query_cache_size + innodb_buffer_pool_size + innodb_additional_mem_pool_size + innodb_log_buffer_size + max_connections + tmp_table_size) x (sort_buffer_size + read_buffer_size + join_buffer_size + read_rnd_buffer_size + thread_stack + binlog_cache_size)

In test VPS the default values were:

64+64+8+1+1+150+32 * 2+.128+.256+.128+.196+0 = 866.56MB used by MySQL

Size per Apache process: Normally between 20-25MB if you run dynamic websites.

MaxClients is, 2048 – (37.2+ 866.56)/20 ~= 57.

If you increase this value, you will see your server swapping often, so either maintain this value for MaxClients or increase the physical memory (RAM).

Configure Apache For Maximum Performance

The default settings need not be changed if the websites receive normal traffic. But once the traffic increases you would need to change the default settings and one should know what values need to be changed and why. Below guide will help you understand most of the Apache directives and what needs to be tweaked.

The first thing to do is to use a tool like “ab” for performance benchmarking:

ab -n 500 -c 10

where n is: number of requests and c is the concurrency level. Run the command before and after the performance tuning and analyze the output. You need to check if the time taken by the webserver to deliver the result has improved.

1. Apache modules and settings

a) mod_reqtimeout


RequestReadTimeout [header=timeout[-maxtimeout][,MinRate=rate] [body=timeout[-maxtimeout][,MinRate=rate]

As seen above, time outs can be set for both request header and body from the client. Set this to a low value to make sure both header and body times out after the configured time.

b) TimeOut

This directive defines the time that Apache process will wait for I/O. The default value is set to 60 seconds and you should lower it to say 10-20 seconds in case of DDOS attacks. Some cgi scripts that need more execution time may face issues due to this.

c) KeepAlive and KeepAliveTimeout

Most of the webhosts disable KeepAlive during DDOS but doing so affects the server’s performance again. A better idea would be to decrease the KeepAliveTimeout to 2 (default 5) and still have the KeepAlive enabled.

d) LimitRequestBody

This defines the allowed size of message body to be allowed. During DDOS attacks, set this server-wide. The default value is 0 which means unlimited. Set that to 100MB and see if improves the performance.


LimitRequestBody value

LimitRequestBody 102400000

e) LimitRequestFields

This directive limits the request header fields from the client. Set this to a value between 40-50
LimitRequestFields 40 (default is 100)

f) LimitRequestFieldSize

This limits the size of the HTTP request header allowed from the client. Default is 8190 and is hard coded when it is recompiled. Decrease this value to half.

LimitRequestFieldSize 4095

g) LimitRequestLine

This limits the size of the HTTP request line that will be accepted from the client.

LimitRequestLine 4095 (default is 8190)

h) LimitXMLRequestBody

This limits the size of an XML type body request.

LimitXMLRequestBody 500000 (defaults to 1000000)

i) MaxRequestWorkers

A webserver should never use SWAP as doing so further decreases the server’s performance and increases the server load drastically. You should regulate this directive to make sure that Apache doesn’t spawn so many child processes as it starts swapping.

j) ServerLimit

It is the upper limit for the number of connections configured for Apache.

k) MaxClients

It is the maximum number of simultaneous connections that will be processed by Apache web server. This value should never exceed the #ServerLimit set. Extra care should be taken into consideration while setting the MaxClients value as any slight variation could badly affect the overall server’s performance.

How to prevent DDOS and SYN flood attacks

Below are some of the kernel values which could mitigate DDOS and SYN floods to a large extend.

You can add these values to /etc/sysctl.conf file or use “sysctl -w” to make online changes.

sysctl -w net.ipv4.netfilter.ip_conntrack_tcp_timeout_syn_recv=45

sysctl -w net.ipv4.netfilter.ip_conntrack_tcp_timeout_established=332000

sysctl -w net.ipv4.tcp_fin_timeout=15

sysctl -w net.ipv4.tcp_synack_retries=5

sysctl -w net.ipv4.tcp_fin_timeout=15

sysctl -w net.ipv4.tcp_keepalive_time=1500

sysctl -w net.ipv4.tcp_sack=0

sysctl -w net.ipv4.tcp_max_tw_buckets=1440000

sysctl -w net.ipv4.tcp_max_syn_backlog=2048

sysctl -w net.ipv4.tcp_max_syn_backlog=4096

sysctl -w net.ipv4.tcp_fin_timeout=20

sysctl -w net.ipv4.tcp_keepalive_time=1800

sysctl -w net.ipv4.tcp_fin_timeout=20

sysctl -w net.ipv4.tcp_keepalive_time=1800

sysctl -w net.ipv4.tcp_keepalive_intvl=40

sysctl -w net.ipv4.tcp_tw_recycle=1

sysctl -w net.ipv4.tcp_tw_reuse=1

sysctl -w net.ipv4.tcp_max_syn_backlog=4096

sysctl -w net.ipv4.inet_peer_gc_maxtime=240

sysctl -w net.ipv4.inet_peer_maxttl=500

sysctl -w net.ipv4.inet_peer_minttl=80

Enjoy hope it will help