Review pipe.incoming.email.for.certain.user.to.external.script.md.
This commit is contained in:
parent
38d01b5619
commit
57d57fc330
|
@ -0,0 +1,69 @@
|
||||||
|
# How to pipe incoming email for certain user to external script
|
||||||
|
|
||||||
|
This tutorial explains how to pipe incoming email for certain user to external script.
|
||||||
|
|
||||||
|
## Configure Postfix to use your external script as transport
|
||||||
|
|
||||||
|
To pipe incoming emails to external script, you must add your external script
|
||||||
|
as Postfix transport program. Please add below line at the bottom of Postfix
|
||||||
|
config file `/etc/postfix/master.cf`:
|
||||||
|
|
||||||
|
```
|
||||||
|
external-pipe unix - n n - - pipe
|
||||||
|
flags= user=vmail:vmail argv=/path/to/your/external/script.sh
|
||||||
|
```
|
||||||
|
|
||||||
|
__Note__:
|
||||||
|
|
||||||
|
* You can use some macros to replace with corresponding information from the
|
||||||
|
Postfix queue manager delivery request. Refer to Postfix manual page for more
|
||||||
|
detail: ()[http://www.postfix.org/pipe.8.html]. For example:
|
||||||
|
|
||||||
|
```
|
||||||
|
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}
|
||||||
|
```
|
||||||
|
|
||||||
|
* the second line needs to be right under the first line and must start with
|
||||||
|
one (or more) whitespace, and the first line cannot start with whitespace,
|
||||||
|
otherwise postfix will fail with `unexpected command-line argument` errors.
|
||||||
|
Also make sure the `user=` line is pointing to a valid user with permissions
|
||||||
|
to execute the script. This user must not be the postfix or root user, otherwise
|
||||||
|
or the pipe will fail.
|
||||||
|
|
||||||
|
Now restart Postfix service to make this new transport available:
|
||||||
|
|
||||||
|
```
|
||||||
|
# /etc/init.d/postfix restart
|
||||||
|
```
|
||||||
|
|
||||||
|
## Update per-user transport to use this new transport
|
||||||
|
|
||||||
|
We need to update per-user transport setting, so that all emails delivered to
|
||||||
|
this user will be piped to this new transport - your script.
|
||||||
|
|
||||||
|
* If you have iRedAdmin-Pro:
|
||||||
|
|
||||||
|
* For iRedAdmin-Pro-LDAP installed, please go to user profile page, under
|
||||||
|
tab `Advanced`, set `Relay/Transport setting` to `external-pipe`. Screenshot for
|
||||||
|
your reference: ()[http://www.iredmail.org/images/iredadmin/user_profile_relay.png]
|
||||||
|
|
||||||
|
* For iRedAdmin-Pro-MySQL or iRedAdmin-Pro-PGSQL installed, please go
|
||||||
|
to user profile page, under tab `Relay`, set `/Transport setting` to
|
||||||
|
`external-pipe`.
|
||||||
|
|
||||||
|
* If you don't have iRedAdmin-Pro, please update LDAP/MySQL/PgSQL database to
|
||||||
|
use this new transport.
|
||||||
|
|
||||||
|
* For OpenLDAP backend, please login to phpLDAPadmin, add new attribute
|
||||||
|
`mtaTransport` for your user, set its value to `external-pipe`.
|
||||||
|
|
||||||
|
* For MySQL/PostgreSQL backend, please execute below command with SQL
|
||||||
|
command line tool (Replace 'user@domain.ltd' by the real email address):
|
||||||
|
|
||||||
|
```mysql
|
||||||
|
sql> USE vmail;
|
||||||
|
sql> UPDATE mailbox SET transport='external-pipe' WHERE username='user@domain.ltd';
|
||||||
|
```
|
||||||
|
|
||||||
|
That's all.
|
|
@ -12,7 +12,7 @@
|
||||||
<h2 id="create-new-mail-account">Create new mail account</h2>
|
<h2 id="create-new-mail-account">Create new mail account</h2>
|
||||||
<p>To create a new mail account with Thunderbird, please click menu: <code>File -> New -> Mail Account</code>.</p>
|
<p>To create a new mail account with Thunderbird, please click menu: <code>File -> New -> Mail Account</code>.</p>
|
||||||
<p>Add your name, email address and password in this screen.</p>
|
<p>Add your name, email address and password in this screen.</p>
|
||||||
<p>[[File:../images/thunderbird.new.mail.account.png]]</p>
|
<p><img alt="" src="images/Thunderbird.new.mail.account.png" title="Thunderbird.new.mail.account.png" /></p>
|
||||||
<p>Click continue, it will detect IMAP and SMTP server automatically.</p>
|
<p>Click continue, it will detect IMAP and SMTP server automatically.</p>
|
||||||
<p>Note:</p>
|
<p>Note:</p>
|
||||||
<ul>
|
<ul>
|
||||||
|
|
|
@ -0,0 +1,80 @@
|
||||||
|
<html>
|
||||||
|
<head>
|
||||||
|
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
|
||||||
|
<title></title>
|
||||||
|
<link href="../../css/markdown.css" rel="stylesheet"></head>
|
||||||
|
</head>
|
||||||
|
|
||||||
|
<body>
|
||||||
|
<h3></h3>
|
||||||
|
<h1 id="how-to-pipe-incoming-email-for-certain-user-to-external-script">How to pipe incoming email for certain user to external script</h1>
|
||||||
|
<p>This tutorial explains how to pipe incoming email for certain user to external script.</p>
|
||||||
|
<h2 id="configure-postfix-to-use-your-external-script-as-transport">Configure Postfix to use your external script as transport</h2>
|
||||||
|
<p>To pipe incoming emails to external script, you must add your external script
|
||||||
|
as Postfix transport program. Please add below line at the bottom of Postfix
|
||||||
|
config file <code>/etc/postfix/master.cf</code>:</p>
|
||||||
|
<pre><code>external-pipe unix - n n - - pipe
|
||||||
|
flags= user=vmail:vmail argv=/path/to/your/external/script.sh
|
||||||
|
</code></pre>
|
||||||
|
|
||||||
|
<p><strong>Note</strong>:</p>
|
||||||
|
<ul>
|
||||||
|
<li>You can use some macros to replace with corresponding information from the
|
||||||
|
Postfix queue manager delivery request. Refer to Postfix manual page for more
|
||||||
|
detail: ()[http://www.postfix.org/pipe.8.html]. For example:</li>
|
||||||
|
</ul>
|
||||||
|
<pre><code>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}
|
||||||
|
</code></pre>
|
||||||
|
|
||||||
|
<ul>
|
||||||
|
<li>the second line needs to be right under the first line and must start with
|
||||||
|
one (or more) whitespace, and the first line cannot start with whitespace,
|
||||||
|
otherwise postfix will fail with <code>unexpected command-line argument</code> errors.
|
||||||
|
Also make sure the <code>user=</code> line is pointing to a valid user with permissions
|
||||||
|
to execute the script. This user must not be the postfix or root user, otherwise
|
||||||
|
or the pipe will fail.</li>
|
||||||
|
</ul>
|
||||||
|
<p>Now restart Postfix service to make this new transport available:</p>
|
||||||
|
<pre><code># /etc/init.d/postfix restart
|
||||||
|
</code></pre>
|
||||||
|
|
||||||
|
<h2 id="update-per-user-transport-to-use-this-new-transport">Update per-user transport to use this new transport</h2>
|
||||||
|
<p>We need to update per-user transport setting, so that all emails delivered to
|
||||||
|
this user will be piped to this new transport - your script.</p>
|
||||||
|
<ul>
|
||||||
|
<li>
|
||||||
|
<p>If you have iRedAdmin-Pro:</p>
|
||||||
|
<ul>
|
||||||
|
<li>
|
||||||
|
<p>For iRedAdmin-Pro-LDAP installed, please go to user profile page, under
|
||||||
|
tab <code>Advanced</code>, set <code>Relay/Transport setting</code> to <code>external-pipe</code>. Screenshot for
|
||||||
|
your reference: ()[http://www.iredmail.org/images/iredadmin/user_profile_relay.png]</p>
|
||||||
|
</li>
|
||||||
|
<li>
|
||||||
|
<p>For iRedAdmin-Pro-MySQL or iRedAdmin-Pro-PGSQL installed, please go
|
||||||
|
to user profile page, under tab <code>Relay</code>, set <code>/Transport setting</code> to
|
||||||
|
<code>external-pipe</code>.</p>
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
|
</li>
|
||||||
|
<li>
|
||||||
|
<p>If you don't have iRedAdmin-Pro, please update LDAP/MySQL/PgSQL database to
|
||||||
|
use this new transport.</p>
|
||||||
|
<ul>
|
||||||
|
<li>
|
||||||
|
<p>For OpenLDAP backend, please login to phpLDAPadmin, add new attribute
|
||||||
|
<code>mtaTransport</code> for your user, set its value to <code>external-pipe</code>.</p>
|
||||||
|
</li>
|
||||||
|
<li>
|
||||||
|
<p>For MySQL/PostgreSQL backend, please execute below command with SQL
|
||||||
|
command line tool (Replace 'user@domain.ltd' by the real email address):</p>
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
|
<pre><code class="mysql">sql> USE vmail;
|
||||||
|
sql> UPDATE mailbox SET transport='external-pipe' WHERE username='user@domain.ltd';
|
||||||
|
</code></pre>
|
||||||
|
|
||||||
|
<p>That's all.</p></body></html>
|
|
@ -12,8 +12,9 @@
|
||||||
<li><a href="/Users/zhb/projects/docs/html/faq-howto/amavisd.no.x-spam.headers.html"> Amavisd + SpamAssassin not working, no mail header (X-Spam-*) inserted.</a></li>
|
<li><a href="/Users/zhb/projects/docs/html/faq-howto/amavisd.no.x-spam.headers.html"> Amavisd + SpamAssassin not working, no mail header (X-Spam-*) inserted.</a></li>
|
||||||
<li><a href="/Users/zhb/projects/docs/html/faq-howto/completely.disable.amavisd.clamav.spamassassin.html"> How to completely disable amavisd/ClamAV/SpamAssassin</a></li>
|
<li><a href="/Users/zhb/projects/docs/html/faq-howto/completely.disable.amavisd.clamav.spamassassin.html"> How to completely disable amavisd/ClamAV/SpamAssassin</a></li>
|
||||||
<li><a href="/Users/zhb/projects/docs/html/faq-howto/disable.spam.virus.scanning.for.outgoing.mails.html"> How to disable spam virus scanning for outgoing mails</a></li>
|
<li><a href="/Users/zhb/projects/docs/html/faq-howto/disable.spam.virus.scanning.for.outgoing.mails.html"> How to disable spam virus scanning for outgoing mails</a></li>
|
||||||
<li><a href="/Users/zhb/projects/docs/html/faq-howto/howto.configure.thunderbird.for.iredmail.html">Configure Thunderbird as mail client (IMAP, SMTP and global ldap address book)</a></li>
|
<li><a href="/Users/zhb/projects/docs/html/faq-howto/howto.configure.thunderbird.for.iredmail.html"> Configure Thunderbird as mail client (IMAP, SMTP and global ldap address book)</a></li>
|
||||||
<li><a href="/Users/zhb/projects/docs/html/faq-howto/howto.enable.smtps.service.html"> How to enable SMTPS service (SMTP over SSL, port 465)</a></li>
|
<li><a href="/Users/zhb/projects/docs/html/faq-howto/howto.enable.smtps.service.html"> How to enable SMTPS service (SMTP over SSL, port 465)</a></li>
|
||||||
|
<li><a href="/Users/zhb/projects/docs/html/faq-howto/pipe.incoming.email.for.certain.user.to.external.script.html"> How to pipe incoming email for certain user to external script </a></li>
|
||||||
</ul>
|
</ul>
|
||||||
<h1 id="backup-and-restore"><a href="/Users/zhb/projects/docs/html/backup-restore/_summary.html">Backup and Restore</a></h1>
|
<h1 id="backup-and-restore"><a href="/Users/zhb/projects/docs/html/backup-restore/_summary.html">Backup and Restore</a></h1>
|
||||||
<ul>
|
<ul>
|
||||||
|
|
|
@ -3,7 +3,8 @@
|
||||||
* [ Amavisd + SpamAssassin not working, no mail header (X-Spam-*) inserted.](/Users/zhb/projects/docs/html/faq-howto/amavisd.no.x-spam.headers.html)
|
* [ Amavisd + SpamAssassin not working, no mail header (X-Spam-*) inserted.](/Users/zhb/projects/docs/html/faq-howto/amavisd.no.x-spam.headers.html)
|
||||||
* [ How to completely disable amavisd/ClamAV/SpamAssassin](/Users/zhb/projects/docs/html/faq-howto/completely.disable.amavisd.clamav.spamassassin.html)
|
* [ How to completely disable amavisd/ClamAV/SpamAssassin](/Users/zhb/projects/docs/html/faq-howto/completely.disable.amavisd.clamav.spamassassin.html)
|
||||||
* [ How to disable spam virus scanning for outgoing mails](/Users/zhb/projects/docs/html/faq-howto/disable.spam.virus.scanning.for.outgoing.mails.html)
|
* [ How to disable spam virus scanning for outgoing mails](/Users/zhb/projects/docs/html/faq-howto/disable.spam.virus.scanning.for.outgoing.mails.html)
|
||||||
* [Configure Thunderbird as mail client (IMAP, SMTP and global ldap address book)](/Users/zhb/projects/docs/html/faq-howto/howto.configure.thunderbird.for.iredmail.html)
|
* [ Configure Thunderbird as mail client (IMAP, SMTP and global ldap address book)](/Users/zhb/projects/docs/html/faq-howto/howto.configure.thunderbird.for.iredmail.html)
|
||||||
* [ How to enable SMTPS service (SMTP over SSL, port 465)](/Users/zhb/projects/docs/html/faq-howto/howto.enable.smtps.service.html)
|
* [ How to enable SMTPS service (SMTP over SSL, port 465)](/Users/zhb/projects/docs/html/faq-howto/howto.enable.smtps.service.html)
|
||||||
|
* [ How to pipe incoming email for certain user to external script ](/Users/zhb/projects/docs/html/faq-howto/pipe.incoming.email.for.certain.user.to.external.script.html)
|
||||||
# [Backup and Restore](/Users/zhb/projects/docs/html/backup-restore/_summary.html)
|
# [Backup and Restore](/Users/zhb/projects/docs/html/backup-restore/_summary.html)
|
||||||
* [How to migrate old iRedMail server to the latest stable release](/Users/zhb/projects/docs/html/backup-restore/migrate.to.new.iredmail.server.html)
|
* [How to migrate old iRedMail server to the latest stable release](/Users/zhb/projects/docs/html/backup-restore/migrate.to.new.iredmail.server.html)
|
||||||
|
|
|
@ -1,46 +0,0 @@
|
||||||
<http://iredmail.org/wiki/index.php?title=IRedMail/FAQ/Pipe.Incoming.Email.For.Certain.User.To.External.Script>
|
|
||||||
#How to pipe incoming email for certain user to external script
|
|
||||||
##Summary
|
|
||||||
|
|
||||||
This tutorial explains how to pipe incoming email for certain user to external script.
|
|
||||||
|
|
||||||
##Configure Postfix to use your external script as transport
|
|
||||||
|
|
||||||
Update file /etc/postfix/master.cf to use your external script as Postfix transport. Add below line at the bottom of file /etc/postfix/master.cf:
|
|
||||||
|
|
||||||
<pre>
|
|
||||||
external-pipe unix - n n - - pipe
|
|
||||||
flags= user=vmail:vmail argv=/path/to/your/external/script.sh
|
|
||||||
</pre>
|
|
||||||
|
|
||||||
__Note__:
|
|
||||||
|
|
||||||
* You can use some macros to replace with corresponding information from the Postfix queue manager delivery request. Refer to Postfix manual page for more detail: http://www.postfix.org/pipe.8.html For example:
|
|
||||||
<pre>
|
|
||||||
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}
|
|
||||||
</pre>
|
|
||||||
|
|
||||||
|
|
||||||
* that the 2nd line needs to be right under the first and must start with whitespace, and the first line cannot start with whitespace or postfix will fail with 'unexpected command-line argument' errors. Also make sure the user= line is pointing to a valid user with permissions to execute the script. This user must not be the postfix or root user or the pipe will fail.
|
|
||||||
|
|
||||||
Now restart Postfix service to make this new transport available:
|
|
||||||
<pre>
|
|
||||||
# /etc/init.d/postfix restart
|
|
||||||
</pre>
|
|
||||||
|
|
||||||
##Update per-user transport to use this new transport
|
|
||||||
|
|
||||||
We need to update per-user transport setting, so that all emails delivered to this user will be piped to this new transport - your script.
|
|
||||||
|
|
||||||
* If you have iRedAdmin-Pro-LDAP installed, please go to user profile page, under tab __Advanced__, set __Relay/Transport setting__ to 'external-pipe' (without quotes). Screenshot for your reference: http://screenshots.iredmail.googlecode.com/hg/iredadmin/user_profile_relay.png
|
|
||||||
* If you have iRedAdmin-Pro-MySQL or iRedAdmin-Pro-PGSQL installed, please go to user profile page, under tab __Relay__, set __Relay/Transport setting__ to 'external-pipe' (without quotes).
|
|
||||||
* If you don't have iRedAdmin-Pro installed, you have to manually update LDAP/MySQL/PgSQL database to use this new transport.
|
|
||||||
* For OpenLDAP backend, please login to phpLDAPadmin, please add new attribute __mtaTransport__ for your user, set its value to 'external-pipe'.
|
|
||||||
* For MySQL/PostgreSQL backend, please execute below command with SQL command line tool (Replace 'user@domain.ltd' by the real email address):
|
|
||||||
<pre>
|
|
||||||
sql> USE vmail;
|
|
||||||
sql> UPDATE mailbox SET transport='external-pipe' WHERE username='user@domain.ltd';
|
|
||||||
</pre>
|
|
||||||
|
|
||||||
That's all.
|
|
Loading…
Reference in New Issue