1

Topic: Piping Script with iRedAdmin

==== Required information ====
- iRedMail version: 0.8.2
- Store mail accounts in which backend (LDAP/MySQL/PGSQL): MySQL
- Linux/BSD distribution name and version:
- Related log if you're reporting an issue:
====

Hi,

I am developing a web project where I am creating dynamic email accounts and as a email comes to these newly created email accounts, I need to perform some db operations. I am using postfix. But the issue is that how can I set my piping script?

A little help is really appreciable.

Thanks.

----

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

2

Re: Piping Script with iRedAdmin

Reference: http://www.iredmail.org/wiki/index.php? … nal.Script

3

Re: Piping Script with iRedAdmin

Hi Zhang,

In my case, I am using dynamic email accounts, so how I will use the dynamic email accounts here? How I pass the email address there?

4

Re: Piping Script with iRedAdmin

sangeeta.arora wrote:

I am using dynamic email accounts

For example?

Your accounts must exist in SQL server first, then why not update proper SQL record to set per-user transport as mentioned in wiki tutorial?

5

Re: Piping Script with iRedAdmin

Hi Zhang,

So it means for each dynamic email account, I must have to do entry in /etc/postfix/master.cf for that email account ? In my application, there may be thousand of email accounts can be created so is it advisable to do so many entry in master.cf? Please suggest.

6

Re: Piping Script with iRedAdmin

Oh, no. You need only one entry in /etc/postfix/master.cf. When you create new mail accounts, please set its per-user transport to this entry by following our wiki tutorial:
http://www.iredmail.org/wiki/index.php? … _transport

7

Re: Piping Script with iRedAdmin

Hi Zhang,

As I told you already that I am creating multiple dynamic email accounts. So, suppose if I have test1@mydomain.com and test2@mydomain.com then how I will do the entry in master.cf? As per Wikki, I have to do the following:-

sql> USE vmail;
sql> UPDATE mailbox SET transport='external-pipe' WHERE username='test1@mydomain.com';

sql> USE vmail;
sql> UPDATE mailbox SET transport='external-pipe' WHERE username='test2@mydomain.com';

and then how it will be in master.cf :-

external-pipe         unix    -       n               n               -               -       pipe
    flags=DRhu user=vmail:vmail argv=/path/to/your/external/script.sh -f ${sender} -d ${user}@${domain} -m ${extension}

Can anyone please explain? How I map it with multiple email accounts?

8

Re: Piping Script with iRedAdmin

sangeeta.arora wrote:

Can anyone please explain? How I map it with multiple email accounts?

You already achieved it. What do you mean "map it with multiple email accounts"?

sangeeta.arora wrote:

    flags=DRhu user=vmail:vmail argv=/path/to/your/external/script.sh -f ${sender} -d ${user}@${domain} -m ${extension}

As defined in master.cf, Postfix will pile email to your script.sh, with option "-f sender@domain.com -d recipient@example.com -m ${extension}". You script should have ability to handle multiple accounts.

9

Re: Piping Script with iRedAdmin

Hi Zhang,

Thanks for your response.

But still I am not clear about how I achieved this? As you told that in master.cf, I will set recipient@example.com. But my issue is that I have multiple email accounts like test1@example.com, test2@example.com, test3@example.com etc. and for each email account how I set the "-d ${user}@${domain} " option in master.cf file? My domain name is fixed but the user is not fixed as it is creating dynamically. It may be test1, test2, test3 or something so I will set this in master.cf file and also how my script file will identify that mail is coming on test1@example.com or test2@example.com or test3@example.com etc.?

10

Re: Piping Script with iRedAdmin

sangeeta.arora wrote:

and for each email account how I set the "-d ${user}@${domain} " option in master.cf file?

Oh, you don't need to change it, just use "-d ${user}@${domain}", it will be substituted by the real email address. That's why i say you need only one entry in master.cf.

If you script doesn't support '-f', '-d', just replace by the valid variables. For example:

    flags=DRhu user=vmail:vmail argv=/path/to/your/external/script.sh --sender=${sender} --recipient=${user}@${domain} --extension=${extension}

11

Re: Piping Script with iRedAdmin

ZhangHuangbin wrote:
sangeeta.arora wrote:

and for each email account how I set the "-d ${user}@${domain} " option in master.cf file?

Oh, you don't need to change it, just use "-d ${user}@${domain}", it will be substituted by the real email address. That's why i say you need only one entry in master.cf.

If you script doesn't support '-f', '-d', just replace by the valid variables. For example:

    flags=DRhu user=vmail:vmail argv=/path/to/your/external/script.sh --sender=${sender} --recipient=${user}@${domain} --extension=${extension}

Thanks a lot Zhang smile

It is working fine now.