WHMCS email pipe

9 posts / 0 new
Last post
#1 Sat, 04/03/2010 - 23:15
rrhode

WHMCS email pipe

Hey there,

I have tried for days to get this to work properly and I am pretty sure I must have read and reread everything I can find on these forums about WHMCS by now. I am trying to set up the trial of WHMCS since I can't find anything that has open source that works any good and everyones raving about it. So I got it set up and finally managed to get email working through cron. However... I want to get it to work through pipe.

I was getting numerous emails from the cron it told me to set up until I added > /dev/null to the end of it. But I still think it would be great to have pipe setup and running properly and securely so I don't have to have yet another cron job running. Or maybe its just because I'm stubborn and don't like settling for second best when I can have the best.

So what exactly do I do?

CentOS 5.4, Virtualmin Pro w/ bleeding edge repos.

Latest ionCube loaders are installed. with the ionCube PHP Loader v3.3.14, Copyright (c) 2002-2010, by ionCube Ltd. Additional Modules ionCube Loader

Here is exactly what I've tried thus far.

Apparently it won't run in fcgi so I tried cgi but gave up on that too and stuck the domain in mod_php though it would really be nice to have fcgi since everything else on the server is running like that. So I put it on FCGId where it is right now. It seems to be working fine except for this pipe thing.

In WHMCS I am at Utilities > PHP info and check it to be sure:

Server API CGI/FastCGI

I have a server hosting.domain.com where WHMCS is installed and running.

I will do a fresh test so you can see exactly what happens.

I create a new mail alias test@hosting.domain.com and I put in the Advanced tab to Feed to Program and paste in exactly what WHMCS gives me... | php -q /home/hosting.domain.com/public_html/pipe/pipe.php

Then it says: Failed to save alias : '' is not a valid program or does not exist

So I change it to php -q /home/hosting.domain.com/public_html/pipe/pipe.php and that goes on and lets me create the alias.

I add that test@hosting.domain.com support department into WHMCS leaving everything as default.

I send an email from Gmail to test@hosting.domain.com and in the /var/log/maillog I have this line:

Apr  3 22:27:26 server1 postfix/local[9202]: 757C9808054: to=<test-hosting.domain.com@server1.server.com>, orig_to=<test@hosting.domain.com>, relay=local, delay=0.34, delays=0.14/0/0/0.21, dsn=5.3.0, status=bounced (Command died with status 1: "php -q /home/hosting.domain.com/public_html/pipe/pipe.php". Command output: Could not open input file: /home/hosting.domain.com/public_html/pipe/pipe.php )

At this point here is what I have for permissions:

/home(755)/hosting.domain.com(750)/public_html(750)/pipe(755)/pipe.php(750)

Except for /home which is set to root:root the rest are owned by hosting:hosting

So I chmod them all to 755 except for pipe.php and sent a test mail to test@hosting.domain.com and it sends back an email with this error:

<test-hosting.domain.com@server1.server.com> (expanded from
    <test@hosting.domain.com>): Command died with status 1: "php -q
    /home/hosting.domain.com/public_html/pipe/pipe.php". Command output: Could
    not open input file: /home/hosting.domain.com/public_html/pipe/pipe.php

Chmod 755 on pipe.php sends back an email with this error:

<test-hosting.domain.com@server1.server.com> (expanded from
    <test@hosting.domain.com>): Command died with status 255: "php -q
    /home/hosting.domain.com/public_html/pipe/pipe.php"

I create a new email user test2@hosting.domain.com.

I create a .forward file at /home/hosting.domain.com/homes/test2/.forward and chown it to test2.hosting.domain.com:hosting and chmod +x .forward.

Then I paste this into it :

"|/home/hosting.domain.com/public_html/pipe/pipe.php"

I go create the test2 support department and leave things as default.

Sending a test mail gets the same error as above with Command died with status 255.

The odd thing now is that each time I get one of these status 255 errors it seems to do something, because in WHMCS when I click Home and go to the main admin screen it now says: 2 Ticket(s) Awaiting Reply However I see no tickets. Is it a cache of WHMCS or something? I don't know, but I don't think so because I didn't get any emails saying there was a new ticket. All I get is Undelivered Mail Returned to Sender back to my Gmail address.

So, any ideas on what to try next? =)

Ryan

Sun, 04/04/2010 - 04:55
ronald
ronald's picture

the cron I successfully use is
php -q /home/path/to/pipefolder/public_html/pipe/pop.php
this is not for forwarding but pop3 import and you need IMAP on the server.

then for the department you need the login credentials set.

Sun, 04/04/2010 - 08:39
rrhode

Hi Ronald,

Thanks for your reply. I actually have cron to pop.php working ok it seems. I had to set my port to 995. But was still trying to get pipe.php to work. I was unable to get pipe to work in a couple other support type applications like this either, likely due to similar errors with permissions or something. I don't know. I just really wanted to make it work and not let it defeat me.

These billing apps are great and clearly a heck of a lot of work has gone into them but I am starting to think about making my own billing app which will be fully built on the Virtualmin API and no other hosting panels, at least for the time being. It would have to be fully open source under the GPL perhaps. It would be simpler to use but yet more fully integrated with Virtualmin and take complete advantage of its powerful API. Maybe I could even use ejabberd chat somehow for a chat system. I am strongly considering a project like this simply because it could be more fully integrated with Virtualmin and be open source so that others can help make it better and hopefully then it could even become more secure and reliable in time. It would probably have to be based on an existing framework of some sort. Maybe Joomla or Drupal or something else like cakePHP, etc. I don't know if going with perl would be good or not considering I don't know it as well as PHP but maybe that would be an even tighter integration. Or maybe I should just learn something new altogether like Ruby or something else.

Ryan

Sun, 04/04/2010 - 11:09
ronald
ronald's picture

at sourceforge there has been many attempts to create billing app. i think this isn't feasible. Searching for billing gives almost 700 results.
An awfull lot of work and it needs to be very secure.
Then all it needs is to talk to virtualmin's API, which seems to be the less difficult part, for automation.

per haps you can hook up to an existing one over there.

Sun, 04/04/2010 - 13:31
rrhode

I think it is very feasible myself. If its possible to make all these closed source systems its definitely possible to make one open source. It will just take a little time. I was trying to avoid doing such a thing to save time in the first place but I am starting to think it would be a great idea and I think it would be well worth it in the end. And hopefully I will learn a thing or two.

Indeed there are a lot of open source billing apps out there but nothing seems to be quite what I'm looking for. Searching for billing on sourceforge gives 690 results. Searching for host billing gives 42. Searching for virtualmin billing gives 1 with no files or anything. Many of these have nothing in them and some aren't even there. Some look like they may be ok to start with as a base but I have already spent a lot of time trying systems out. If you can point out a good one to try I would love to give it a shot. Maybe you are saying it would be at least good to start with something rather than nothing but thats why I think I should at least start with some kind of a framework. Maybe I can find a framework which supports paypal and other gateways already so that it might be easy to expand upon if such a thing should happen in the future. I haven't looked into frameworks too much yet but it seems like its the way to go at this point.

I checked out many open source apps already but they either were not very good or seemed like a lot of work to make work and look good and in many cases they simply would not work without messing with them for a long time if they worked at all. I just don't think they would be very easy for a client to use not to mention they didn't seem to have any integration with Virtualmin. So it seemed to be taking more time than it was worth... I probably could have chosen a framework and set up an interface by now instead of messing with all these billing apps. I am hoping to have something extremely simple and to the point from a client perspective but yet powerful and have implemented as much of the Virtualmin API into it as possible and of course also secure. Hopefully the right framework will also help to ensure security a little. Right now I only plan on using paypal or maybe 2checkout since those are all I have accounts for at the moment. I don't plan on storing credit card info, I will leave that to the payment processors.

So I guess the search for a framework is on...

Sun, 04/04/2010 - 15:04
ronald
ronald's picture

Joomla is used very often in the hosting business. There are even hosting billing components (free and also expensive ones) for them and a joomla integrator for whmcs.

It wouldn't be very hard for a programmer to integrate a billing app as a component into joomla or to fuzzle per haps with virtuemart which is already a decent shop.

Sun, 04/04/2010 - 17:30
tpnsolutions
tpnsolutions's picture

Hi,

I've done piping many times, and here is the code to direct piping from email to script:

  1. Create a file called .procmailrc inside the home directory.

  2. Download my attached sample procmail file, then enter the content into your own.

  3. Adjust the "email@address.com" to meet your needs, and the $HOME/public_html/pipe/pipe.php if needed. $HOME just saves you from having to enter the full path to the public_html folder

  4. *** Make your "pipe.php" script executable. ***

  5. Restart Dovecot and Postfix (optional)

  6. Send an email to the email address you put in place of "email@address.com" above.

If you are still having problems, please drop me a line at: pknowles@tpnsolutions.com and I'll help you make sure that everything is properly configured.

Most issues beyond doing the above are minimal, and can be resolved within a half hour tops.

I run multiple Virtualmin servers (currently 5) and know my way around pretty good.

-Peter

Best Regards,
Peter Knowles | TPN Solutions
Email: pknowles@tpnsolutions.com | Skype: tpnassist
Sun, 04/04/2010 - 17:41
rrhode

Nice, thank you Peter! I will give it a shot. I am guessing it will work just fine.

You know, I was considering using Joomla for a start. I do know Joomla very well and have been making templates, extensions and sites with it since it was Mambo. I was debating whether to go with Drupal, Joomla, CakePHP or maybe even Symphony. I don't know if I should keep checking around or not though because I do really know and like Joomla already. But I am just wondering if I should wait for Joomla 1.6 to start a new big project in it so I don't get done just in time to recreate the entire thing over again. Maybe it wouldn't be so hard to go from 1.5 to 1.6 though.

Sat, 04/10/2010 - 18:47
rrhode

Ok, so I finally figured out the problem with piping in WHMCS.

display_errors has to be off in php.ini and templates_c folder has to be chmod to 666.