LinuxQuestions.org
Go Job Hunting at the LQ Job Marketplace
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Server
User Name
Password
Linux - Server This forum is for the discussion of Linux Software used in a server related context.

Notices


Reply
 
Search this Thread
Old 09-08-2010, 06:01 PM   #1
Adrian232
LQ Newbie
 
Registered: Sep 2010
Posts: 4

Rep: Reputation: 0
Question Postfix pipe help


I am trying to set up a pipe for our new helpdesk software on our linux server.

We have a heavily customized configuration of Postfix running that was set up years ago. It uses cyrus for IMAP/POP mailbox delivery, amavis (SpamAssassin/ClamAV) content filtering, and stores all our many user accounts in a MySQL database.

Basically what I want it to do is this:
redirect all mail sent to helpdesk@mydomain.com directly to a local cgi script the second it is picked up by postfix (before any spam filtering, mailbox delivery, etc) and recognize helpdesk@mydomain.com as a valid mailbox destination. All without turning our whole mail system upside-down and inside-out.

I have tried many different things that I have found online, such as using transport_maps, mailbox_transport_maps, and using a pipe (|/path/to/file) instead of a username in the alias map. None of these seem to do anything, and the mail is either rejected for invalid destination, or it is sent to a mailbox without piping.

Please help!
-Adrian
 
Old 09-09-2010, 06:04 PM   #2
Eduardo Nunes
LQ Newbie
 
Registered: Aug 2010
Location: /root/SouthAmerica/Brazil/SaoPaulo/SP
Distribution: Slackware
Posts: 24

Rep: Reputation: 2
Post

Quote:
Originally Posted by Adrian232 View Post
I am trying to set up a pipe for our new helpdesk software on our linux server.

We have a heavily customized configuration of Postfix running that was set up years ago. It uses cyrus for IMAP/POP mailbox delivery, amavis (SpamAssassin/ClamAV) content filtering, and stores all our many user accounts in a MySQL database.

Basically what I want it to do is this:
redirect all mail sent to helpdesk@mydomain.com directly to a local cgi script the second it is picked up by postfix (before any spam filtering, mailbox delivery, etc) and recognize helpdesk@mydomain.com as a valid mailbox destination. All without turning our whole mail system upside-down and inside-out.

I have tried many different things that I have found online, such as using transport_maps, mailbox_transport_maps, and using a pipe (|/path/to/file) instead of a username in the alias map. None of these seem to do anything, and the mail is either rejected for invalid destination, or it is sent to a mailbox without piping.

Please help!
-Adrian
I guess you haven't googled much.. this may be what you are looking for http://forum.parallels.com/showthread.php?t=99358.

Or, you can code a simple content filter, which will check if the recipient is helpdesk@domain and deliver to the right place on the proper format; else it reinjects on postfix or pipe to another content filter (such as spamassassin/amavisd).
 
Old 09-10-2010, 05:51 AM   #3
Noway2
Senior Member
 
Registered: Jul 2007
Distribution: Ubuntu 10.10, Slackware 64-current
Posts: 2,124

Rep: Reputation: 778Reputation: 778Reputation: 778Reputation: 778Reputation: 778Reputation: 778Reputation: 778
It looks like you have two things that need to be worked out: identifying helpdesk@mydomain as a recipient and second, routing it to the script instead of a mail box. Add to this the constraint that you don't want to turn the system upside down. The easiest, least invasive way I can think to do this is to add helpdesk@mydomain as a relay domain and forward this email to a second mail server that then pipes mail to the script. This would at least allow you to isolate the existing postfix system from one that is running the script and buy you some room to work and experiment because I don't think this is going to be easy or straight forward to figure out.

To handle this in postfix, either as the one server or as a separate one, you will undoubtedly need to mess with the master.cf file. That controls the delivery agents. I am not an expert in configuring that file, but one thing that may point you in the right direction would be some of the tutorials on using amavis. Typically with amavis, you will receive mail on port 22, then re-direct it out a non standard port to amavis and then receive it back on another non standard port. I think what you ultimately want is something similar - but to use the pipe delivery instead of smtp delivery.
 
Old 09-10-2010, 02:26 PM   #4
Noway2
Senior Member
 
Registered: Jul 2007
Distribution: Ubuntu 10.10, Slackware 64-current
Posts: 2,124

Rep: Reputation: 778Reputation: 778Reputation: 778Reputation: 778Reputation: 778Reputation: 778Reputation: 778
I wanted to follow up on this subject. I was reading in the book Postfix the definitive guide and I cam across something that I think may have your answer. There are a couple of steps you would need to follow and a couple of things you will need to alter, in both main.cf and master.cf

For this example, I will assume that the pipe 'file' is /var/example/pipefile.

In order to get postfix to handle helpdesk@mydomain.com, via a pipe process, you will need to first create or note the user account under which the pipe will execute. You may want to create a new pseudo account for this with limited privileges.

In your master.cf you will need to add an entry for this recipient as follows:
helpdesk unix - n n - - pipe
flags= user=pipeuser argv=/var/example/pipefile ${sender}

Note the I used 'helpdesk' here. the sender is an optional variable that you can pass and you may want sender and or recipient.

Next add an entry to your transport table that will be used to send messages from helpdesk@mydomain.com to the helpdesk transport (the helpdesk I used above). This can be a simple hash like this:
helpdesk@mydomain.com helpdesk

Then run postmap command against your transport table. Add the hash file to you transport maps variable in main.cf. For example, transport_maps = hash:/etc/postfix/transport. You may need to modify this step per your configuration. The idea is that my putting helpdesk in the transports maps, it will direct mail to helpdesk@mydomain.com to the helpdesk delivery function specified in your master.cf, which in turn sends the data to the write-end of your pipe.
 
1 members found this post helpful.
Old 09-13-2010, 01:01 PM   #5
Adrian232
LQ Newbie
 
Registered: Sep 2010
Posts: 4

Original Poster
Rep: Reputation: 0
Quote:
Originally Posted by Noway2 View Post
I wanted to follow up on this subject. I was reading in the book Postfix the definitive guide and I cam across something that I think may have your answer. There are a couple of steps you would need to follow and a couple of things you will need to alter, in both main.cf and master.cf

For this example, I will assume that the pipe 'file' is /var/example/pipefile.

In order to get postfix to handle helpdesk@mydomain.com, via a pipe process, you will need to first create or note the user account under which the pipe will execute. You may want to create a new pseudo account for this with limited privileges.

In your master.cf you will need to add an entry for this recipient as follows:
helpdesk unix - n n - - pipe
flags= user=pipeuser argv=/var/example/pipefile ${sender}

Note the I used 'helpdesk' here. the sender is an optional variable that you can pass and you may want sender and or recipient.

Next add an entry to your transport table that will be used to send messages from helpdesk@mydomain.com to the helpdesk transport (the helpdesk I used above). This can be a simple hash like this:
helpdesk@mydomain.com helpdesk

Then run postmap command against your transport table. Add the hash file to you transport maps variable in main.cf. For example, transport_maps = hash:/etc/postfix/transport. You may need to modify this step per your configuration. The idea is that my putting helpdesk in the transports maps, it will direct mail to helpdesk@mydomain.com to the help help-desk delivery function specified in your master.cf, which in turn sends the data to the write-end of your pipe.
This looks more like what I'm looking for, I have not tried transport_maps and will see if that works any better. I already have a similar line in my master.cf file for helpdesk that I have tried to use with other parameters in main.cf.

The problem with most of the help I have found online is that they require a physical user in the unix /etc/passwd whereas ours are stored in a database so as to not allow shell access, etc. and to work with other webapps. So to create a user, we set the virtual_aliases table to map to a database table which redirects to the proper Cyrus mailbox.


I will try this and let you know how it works.
 
Old 09-13-2010, 08:11 PM   #6
Adrian232
LQ Newbie
 
Registered: Sep 2010
Posts: 4

Original Poster
Rep: Reputation: 0
transport_maps worked like a charm!

I only had one problem: I couldn't seem to get a specific email address to redirect with our system. So instead I created the subdomain @helpdesk.mydomain.com and have all mail from there redirect to our helpdesk script. Not ideal, but works for our needs.

Here is the final setup (edited with domains changed):

master.cf:
helpdesk unix - n n - 1 pipe
flags=Rq user=apache directory=/var/www/subdomain/helpdesk/ argv=/var/www/subdomain/helpdesk/mailboxpro.cgi ${sender} ${recipient}

main.cf:
transport_maps = hash:/etc/postfix/transport

/etc/postfix/transport:
helpdesk.mydomain.com helpdesk:

And the success message in /var/maillog:
Sep 13 20:46:41 server_01 postfix/pipe[3404]: 29DCD114C0EC: to=<reply@helpdesk.mydomain.com>, relay=helpdesk, delay=0.76, delays=0.02/0.02/0/0.72, dsn=2.0.0, status=sent (delivered via helpdesk service)


A very common sense, and easily implemented solution!
 
Old 09-14-2010, 04:52 AM   #7
Noway2
Senior Member
 
Registered: Jul 2007
Distribution: Ubuntu 10.10, Slackware 64-current
Posts: 2,124

Rep: Reputation: 778Reputation: 778Reputation: 778Reputation: 778Reputation: 778Reputation: 778Reputation: 778
I am glad that this is working for you. A couple of days ago, I also read something in the postfix book about there being four combinations for delivery involving unix accounts and virtual accounts, there were two methods for each. I don't recall the specifics of that section off hand, but I will look later today when I have a little more time and see what it says. I think it may have, at least partially, explained how to forward / alias a specific virtual email address, like you are after.
 
Old 09-15-2010, 04:22 AM   #8
Noway2
Senior Member
 
Registered: Jul 2007
Distribution: Ubuntu 10.10, Slackware 64-current
Posts: 2,124

Rep: Reputation: 778Reputation: 778Reputation: 778Reputation: 778Reputation: 778Reputation: 778Reputation: 778
Follow up: I did some checking and here is what I have found:

To deliver mail to the virtual domain, helpdesk@mydomain.com, you would first put mydomain.com in your virtual_mailbox_domains. As you are already using this domain with virtual users, I am sure this was already done. If you have multiple, or many, you can list these in a file. As you are using virtual domains, these will be delivered either to a maildir or mailbox and this will depend on your pop/imap server. If the mailbox name has a slash at the end, it will be in maildir format. Since this part should be working, I won't go into details on the setup, but you may need to note the locations and select what you want for your helpdesk account.

Next, it is possible to create a virtual alias to have some addresses forwarded to another account. You will want to put this in your virtual_alias_maps. You can then put helpdesk@mydomain.com redirect-here@mydomain.com in the list or in the file (make sure you use postmap, restart, etc) and it should then redirect the virtual helpdesk@mydomain.com to whatever you select for your helpdesk recipient (redirect-here).

Finally, since you were working with your transport_maps, you might need to look into the virtual_transport. The virtual_transport is configured like this: virtual_transport = lmtp:unix:/var/imap/socket/lmtp. This will cause the the virtual_mailbox_domains to be delivered to the POP/IMAP over LMTP (local mail delivery). Note, virtual mailbox_maps is for which accounts have mailbox/maildir recipients. I am pretty certain that you don't want to list a recipient, domain, etc in both the mailbox or domain maps AND the virtual_xxx_maps, only in one or the other.
 
1 members found this post helpful.
Old 09-15-2010, 02:34 PM   #9
Adrian232
LQ Newbie
 
Registered: Sep 2010
Posts: 4

Original Poster
Rep: Reputation: 0
Quote:
Originally Posted by Noway2 View Post
Next, it is possible to create a virtual alias to have some addresses forwarded to another account. You will want to put this in your virtual_alias_maps. You can then put helpdesk@mydomain.com redirect-here@mydomain.com in the list or in the file (make sure you use postmap, restart, etc) and it should then redirect the virtual helpdesk@mydomain.com to whatever you select for your helpdesk recipient (redirect-here).
This idea worked well. I set in our database to forward helpdesk@mydomain.com to reply@helpdesk.mydomain.com, which causes the mail to be sent to the helpdesk pipe. So now our helpdesk messages are sent with helpdesk@mydomain.com, which looks nicer and works better in the process.

Thanks again!
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Postfix Pipe ending, final delivery not performed ! guy_lux Linux - Server 2 08-15-2009 11:59 AM
PING .... pipe 2 vs pipe 3 hanen03 Linux - Networking 1 04-10-2009 10:50 AM
Postfix: postfix: fatal: chdir(/usr/libexec/postfix) Micro420 Ubuntu 2 07-13-2008 12:21 PM


All times are GMT -5. The time now is 12:51 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration