Another day, another dent in the wall. And yet my head remains intact...
I'm currently installing osTicket for my most complex server. With 3 sites (and more in the pipeline), thousands of users and what is normally a complex task list of internal support requests, it's been on my mind that I need to have as support desk system running. Primarily for us to manage the internal support and development tasks, but also so the site administrators can have a more efficient way of dealing with user support requests rather than the somewhat slapdash forum that's in use currently.
So I researched the various open source options out there.
There are a bunch of thing to consider when choosing a support system that I won't go into here, but if you are looking into it, here's a good place to start:
TechRepublic.com | 10 things to consider when choosing a help desk system [new window]
With these considerations in mind, my key requirements were:
Open Source
PHP/MySQL driven
Email & Web interface
The system that I chose then was osTicket as it seems to fulfil these requirements. And their website didn't look like shit. Call me shallow, but I never trust software supplied by someone who has an ugly website with bad UI. There really should be a symbiotic relationship between your ability to create functional software, and present it. If you can't design and code a good site, it's less likely that your software will be any good - especially when it's a web application!
Installation is straight forward and painless - typical web based configuration script. Quite happy with that. Then it gets a little more complex.
[Update] I later notice that osTicket is available for installation via the Plesk Application Vault. How well this works, I don't know. Can't say I trust the Plesk interface do do much at the moment![/Update]
In order for emails to be processed by the software, you need to be able to pipe it to the osTicket script. To do that you need one of two things - cPanel or root access.
cPanel, while limited in certain ways, has some really good features - like the ability to set up email pipes without needing root access. osTicket's wiki even tells you how to do this:
osTicket wiki | Email Piping [new window]
Plesk by contrast can be incredibly powerful, but omits such simple functionality, so a little more knowledge is required. Luckily the process isn't too painful, if you don't balls it up. Plesk uses postfix mail server by default - if you use something different DO NOT follow these instructions. They won't work!
To check if you have Postfix, look for a /etc/postfix folder.
File locations may vary dependant on OS flavour and if you don't use Plesk.
The instructions are provided as is and without warranty of any sort. Y'know - be careful! I knocked out the mail server for an entire night without realising, which is why I'm trying to share the benefit of my errors, but don't blame me if you do worse.
Read the instructions through fully before continuing, and proceed with caution.
You will be creating a pipe command with a unique name. You can name it what you want. I called mine pipeSupportEmail. In the following instructions I use the placeholder {pipeName}. Be sure to use your unique name to replace all instances.
Step 1
SSH in to your server.
Back up main.cf for postfix and then edit it. I use VI.
There should be a copy of main.cf.default, but this probably won't match your working version.
# cp /etc/postfix/main.cf /etc/postfix/main.cf.bak
# vi /etc/postfix/main.cf
Find 'transport_maps'. To do this in vi, hit [esc] to enter command mode and type
/transport_maps
and hit [return].
Note: There is only one incidence of this in the file, but if you ever need to repeat a search in VI, just hit /[return]
You need to add to the line an option 'hash:/var/spool/postfix/plesk/{pipeName}', so after editing it should read:
transport_maps = hash:/var/spool/postfix/plesk/transport, hash:/var/spool/postfix/plesk/{pipeName}
Note: This MUST be all on ONE line
If you have multiple pipes you will enter them all consecutively, so if you had three line might look like this:
transport_maps = hash:/var/spool/postfix/plesk/transport, hash:/var/spool/postfix/plesk/{pipeName}, hash:/var/spool/postfix/plesk/{pipeNameB}, hash:/var/spool/postfix/plesk/{pipeNameC}
Again, this would be all on ONE line.
Once done, save and quit - (in VI [esc]:wq[return])
Step 2
Create a new file /var/spool/postfix/plesk/{pipeName}
This is a transport_map file and will direct all mail sent to your chosen addresses into the pipe (see, the internet really is a series of tubes...)
# vi /var/spool/postfix/plesk/{pipeName}
Add all the email addresses that should be piped to your software in the following format:
{address}@{domain.tld} {pipeName}:{logDescription}
{address}@{domain.tld} {pipeName}:{logDescription}
Where {logDescription} is a note for the mail log. Make this meaningful and unique - then you can easily search the log for it, and distinguish the messages.
So a file might read:
support@company.com pipeSuportEmailt:osTicket support piped
internalsupport@company.com pipeSuportEmail:osTicket internalsupport piped
sales@company.com pipeSuportEmail:osTicket sales piped
Save and close the file.
With these rules in place I can search my mail log later for osTicket to check whether mail is being piped.
Step 3
Hash the file we just created as postfix wants a database file to work with
postmap /var/spool/postfix/plesk/{pipeName}
If you run 'ls /var/spool/postfix/plesk/' you will see there is now a file called {pipeName}.db
Step 4
The last step of coding is to tell postfix which script or program all the email will be piped to, by editing master.cf. Kinda important I suppose...
Oh yeah - BACKUP FIRST!
# cp /etc/postfix/master.cf /etc/postfix/master.cf.bak
# vi /etc/postfix/master.cf
Search for 'plesk_saslauthd', and on the NEXT line, enter the following ALL ON ONE LINE:
{pipeName} unix - n n - - pipe flags=Fq user=apache:apache argv={pathToPipe} ${sender}
{pathToPipe} is the path to the script you want to pipe to. In the case of osTicket this will probably be /var/www/vhosts/{domain}/httpdocs/{osTicketLocation}/api/pipe.php
Again, {domain} and {osTicketLocation} will depend on your installation.
IMPORTANT: {sender} is NOT to be replaced - it is the script variable ${sender}, being the email address the message was sent from
IMPORTANT: Ensure the are NO spaces after ${sender} or postfix will throw it's toys out of the pram.
If you have multiple pipes to different scripts or programs, enter each one on a new line.
Step 5
Restarting postfix seems like the easiest part of the process, but if you have made a mistake, it doesn't complain much, so first, open a new SSH terminal, and tail your mail logfile so you can see if any errors are thrown:
# tail -f /usr/local/psa/var/log/maillog
This will watch the tail of the file, and you will see activity logged as it happens.
The name and location of your maillog may vary if you are using a different version of Plesk, or not using Plesk at all.
Now you can restart postfix
# postfix reload
If it complains that postfix is not running, you can try 'postfix start' instead, but if postfix isn't running, you have another problem with you mail server, and it might not start - look to the mail log for information on what's going wrong.
These instructions based on Nexology Community | Creating Email Pipe with Plesk 9.2.2 [new window]
[Update]Oh dear, it doesn't seem to work yet.
From the maillog:
Oct 1 14:10:39 serverXXX-XX pipe[9594]: fatal: pipe_command: execvp /var/www/vhosts/{domain}.com/subdomains/support/httpdocs/api/pipe.php: Permission denied
Oct 1 14:10:39 serverXXX-XX postfix/pipe[9088]: EF2541117B5: to=<support@{domain}.com>, relay=pipeSupportEmails, delay=3.5, delays=3.4/0/0/0.02, dsn=4.3.0, status=deferred (temporary failure. Command output: pipe: fatal: pipe_command: execvp /var/www/vhosts/{domain}.com/subdomains/support/httpdocs/api/pipe.php: Permission denied )
This is not an uncommon error, but none of the suggested solutions I have found online yet resolve it. I will update when I have more idea.
It would seem (perhaps obviously) to just be a matter of setting the permissions correctly, but I've clearly not worked out just how they should be set.[/Update]
Piping with qmail
If your setup uses qmail rather than postfix, these instructions may help. BE WARNED - I have not tested this:
Do this for each address that you wish to be piped to osTicket
# vi /var/qmail/mailnames/yourdomain.com/{address@domain.com}/.qmail
Where {address@domain.com} is the address you are receiving mail to - e.g. support@somecompany.com
Add the following as the FIRST line of the file:
| php -q /var/www/vhosts/{domain}/httpdocs/{osTicketLocation}/api/pipe.php
Save and quit.
Restart qmail
# service qmail restart
Hmm. I'm jealous now... That looks really simple.
[Update 4-10-2010]I've also found this advice on Plesk with qmail:
Plesk, Email Piping/Email Pipe (osTicket / Trellis) | Steve Jameson [new window]