Topic: Email Piping


I have installed and setup iredmail on our server, which is working fine.

Now for one of the softwares installed on the server, I need to put a email pipe. How do I accomplish this ? I have searched a lot, and have checked the forums, but could not find guidance in this regard.

I have a email addresss myself@our-email-server.com, and the mails coming to it have to be piped to a perl script.

Waiting for guidance.

Thank you.



Re: Email Piping

Define a transport in postfix master.cf, and set per-user transport of your user to the new one.


Re: Email Piping

Yep, I updated my master.cf file with,

myself unix - n n - - pipe
flags=Fq user=vmail:vmail argv=/var/www/cgi-bin/mail-piper.pl

And /etc/postfix/transport file with ,

myself@our-email-server.com myself:delivered to pipe service

And restarted postfix.

Ofcourse the mail was delivered to the email account, but was not sent to the pipe script sad

Sorry.. I am just in the learning curve, so if any mistake in understanding or posted here, please pardon.



Re: Email Piping

jayeshjayan wrote:

And /etc/postfix/transport file with ,

iRedMail doesn't use /etc/postfix/transport by default, you should change iRedMail settings in postfix main.cf to use it. e.g.

transport_maps = hash:/etc/postfix/transport, ...

P.S. *PERSONALLY*, i recommend you use LDAP/MYSQL to store transport if your server load is not high.


Re: Email Piping


Thanks a lot. That fixed the issue.

I shall surely check into your recommendation of using mysql for storing transport maps also.

Thank you once again.




Re: Email Piping

jayeshjayan wrote:

I shall surely check into your recommendation of using mysql for storing transport maps also.

Sorry, i'm not clear in the post.

iRedMail stores transport_maps in MySQL/LDAP by default, so i recommend you not to use another transport file. that's what i mean.


Re: Email Piping


I understood your guidance wrongly, sorry.

I am now clear on this, and I am working in this direction. If I meet any roadblock, shall surely bounce back to the community.

The guidance has been really good, and I would certainly use more of iredmail.

Once again, Thanks a lot.




Re: Email Piping


I think I am halfway done, and got the email piping working fine.. Now the issue is the mails are not delivered to the original email address.

My main.cf and  master.cf files now look like

transport_maps = hash:/etc/postfix/transport, proxy:mysql:/etc/postfix/mysql_transport_maps_user.cf, proxy:mysql:/etc/postfix/mysql_transport_maps_domain.cf


# Other external delivery methods.
www unix - n n - - pipe
   flags=Fq user=vmail:vmail argv=/var/www/cgi-bin/scripts/check_mail.pl 

Can you tell me where I went wrong ?


Re: Email Piping

jayeshjayan wrote:

Now the issue is the mails are not delivered to the original email address.

This is issue of your transport program 'check_mail.pl'.

Postfix pipes RAW email to transport program, normally, transport delivers it to mailbox and stops. You have to make your transport program save a copy or forward the original email to original recipient before/after it was delivered.

10 (edited by ze 2010-05-20 16:27:46)

Re: Email Piping


I know you can use procmail without the transport.  How I wish sieve can pipe the email to scripts.  If you want, I will dig around my test iredmail system for some pointers.  I think you have to set the procmail in the postifx and have some way for the procmail to find the user's .procmailrc like nfs mount.

Here is part of the /etc/procmailrc.  Please note that I haven't use it on production system.  The only thing to note is the SWITCHRC.   It is just my hack on the user's home directory.  Maybe someone can have a better code. smile  Basically it will process /etc/procmailrc and switch to the user's .procmailrc.

# Set Maildir path.


# Variables for vacation.

# Log some message to LOGFILE."
#LOG="--------- Found something. ----------"

# Make sure Maildir exist.
* ? [ -d ${MAILBOX} ] || mkdir -p $MAILBOX
{ }

# Drop spam mail to Junk directory.
:0 H
* ^X-Spam-Status: YES

SWITCHRC="`/usr/bin/getent passwd $USER | cut -d : -f6`/.procmailrc"