I spent a good half a day figuring out how to setup Email Piping properly for WHMCS. If you’ve been having trouble getting Email Piping working or if you’re like me and you simply want to save some money then this is a must read. This free method does not require a cPanel license nor an additional Google Apps account!
First of all, the main documentation for Email Piping is available at http://docs.whmcs.com/Email_Piping. If you’re using cPanel or DirectAdmin, great, use the Forwarder Method and you should be piping emails no problem. I successfully use this method over at Rax Hosting.
If you’re using some other type of control panel you will need to use the Cron Piping Method. I like to use Virtualmin/Webmin to administer a VPS or two. The funny thing about the WHMCS documentation is that it explains little . There are instructions for configuring Google Apps for the Cron Piping Method at http://docs.whmcs.com/Email_Piping:_Google_Apps. The fact that pipe.php and pop.php are obfuscated with IonCube also does not help in understanding what you’re actually doing.
Anyways, the key to getting the Cron Piping Method to work is that you need to configure a single POP3 mailbox in which you can authenticate via firstname.lastname@example.org.
The main problem I had with Virtualmin is that I didn’t understand that I only needed a POP3. I also didn’t understand default Username Conventions to begin with: https://www.virtualmin.com/documentation/email/pop-and-imap
I’ll walk you through step by step on setting up the POP3 accounts in Virtualmin.
Step 1 – Change default Username Convention (Mail) from username-domain to username@domain
1. Select any virtual domain. You may select any domain even one configured for Google Apps as we will be creating a new subdomain strictly for mail piping.
2. Systems Settings > Server Templates
3. Default Settings
4. Select “Mail for domain” on the “Edit template section” dropdown.
5. Scroll to the very bottom and select “user@domain” from “Format for usernames that include domain” dropdown.
Step 2 – Create sub-server
1. Create Virtual Server
2. Select “Sub-server” for New virtual server type and enter a unique subdomain.
3. Disable all features except:
Spam filtering enabled?
Mail for domain enabled?
Virus filtering enabled?
4. Create Server
Step 3 – Create user
1. Select newly created subdomain and click “Edit Users”.
2. Click “Add a user to this server.” Enter a WHMCS support department username.
3. Repeat for all departments.
Step 4 – Create MX record
1. Point subdomain to new mail server
Step 5 – Start POP3 Server (Dovecot) and test
1. Webmin > Servers > Dovecot IMAP/POP3 Server > Start Dovecot Server
2. Send a test email to one of the new users.
3. Check message delivery via shell:
[root@ns0 dk]# telnet localhost pop3
Connected to localhost.
Escape character is ‘^]’.
+OK Dovecot ready.
+OK Logged in.
+OK 3 messages:
+OK Logging out.
Connection closed by foreign host.
Step 6 – Configure and test email piping cron
1. Webmin > System > Scheduled Cron Jobs
2. Click “Create a new scheduled cron job.”
3. Enter command.
5. Return to cron list and select newly created cron.
6. Click “Run Now”:
Output from command php -q /home/user/public_html/portal/pipe/pop.php ..
POP Import Log
Date: 09/07/2015 04:40:37
Email Count: 3
Email Count: 0
Email Count: 0
Success! As you can now see, all the cron really does is login to the POP3 mailbox to import messages. The next step is to “mask” the email address. We do this by creating an alias that automatically forwards the subdomain to the root domain. I’ll explain this in detail in Part 2.