1

Topic: Email Piping

Hello,

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.

Regards,
Jayesh

----

Spider Email Archiver: On-Premises, lightweight email archiving software developed by iRedMail team. Supports Amazon S3 compatible storage and custom branding.

2

Re: Email Piping

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

3

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.


Regards,
Jayesh

4

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.

5

Re: Email Piping

Hello,

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.

Regards,

Jayesh.

6

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.

7

Re: Email Piping

Hello,

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.

Regards,

Jayesh

8

Re: Email Piping

Hello,

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

and

# 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 ?

9

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

Hi,

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.
MAILBOX="/mail/vmail01/$DOMAIN/$USER/Maildir/"
DEFAULT="$MAILBOX"
JUNK="${MAILBOX}/.Junk/"

RECIPIENT="${RECIPIENT}"
SENDER="${SENDER}"

# Variables for vacation.
#VACATION_ON="${MAILBOX}/.vacation.on"
#VACATION_CACHE="${MAILBOX}/.vacation.cache"
#VACATION_LOCK="${MAILBOX}/.vacation.lock"
#VACATION_MSG="${MAILBOX}/.vacation.msg"
#VACATION_SIGNATURE="${MAILBOX}/.vacation.signature"

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

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

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

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

Jacky