Replace python/python2 by python3 in iredapd tutorial.

This commit is contained in:
Zhang Huangbin 2020-07-06 10:56:05 +08:00
parent e7e0cc05cb
commit 18936f1cb7
2 changed files with 58 additions and 48 deletions

View File

@ -7,6 +7,11 @@
All iRedAPD features listed in current page can be managed with our
web-based admin panel - [iRedAdmin-Pro](https://www.iredmail.org/admin_panel.html).
!!! attention
iRedAPD-4.0 and later releases requires Python 3, if you're running
iRedAPD-3.6 or earlier release, please run commands with Python 2 instead.
## Introduce iRedAPD
iRedAPD is a simple Postfix policy server, written in Python, with plugin
@ -178,25 +183,25 @@ White/blacklisting is controlled by plugin `amavisd_wblist` (file
* Show and add server-wide whitelists or blacklists:
```
# python wblist_admin.py --list --whitelist
# python wblist_admin.py --list --blacklist
python3 wblist_admin.py --list --whitelist
python3 wblist_admin.py --list --blacklist
# Whitelist IP address, email address, entire domain, subdomain (including main domain)
# python wblist_admin.py --add --whitelist 192.168.1.10 user@domain.com @iredmail.org @.example.com
python3 wblist_admin.py --add --whitelist 192.168.1.10 user@domain.com @iredmail.org @.example.com
# Blacklist IP address, email address, entire domain, subdomain (including main domain)
# python wblist_admin.py --add --blacklist 202.96.134.133 bad-user@domain.com @bad-domain.com @.sub-domain.com
python3 wblist_admin.py --add --blacklist 202.96.134.133 bad-user@domain.com @bad-domain.com @.sub-domain.com
```
* For per-user or per-domain whitelists and blacklists, please use option
`--account`. for example:
```
# python wblist_admin.py --account @mydomain.com --add --whitelist 192.168.1.10 user@example.com
# python wblist_admin.py --account user@mydomain.com --add --blacklist 172.16.1.10 baduser@example.com
python3 wblist_admin.py --account @mydomain.com --add --whitelist 192.168.1.10 user@example.com
python3 wblist_admin.py --account user@mydomain.com --add --blacklist 172.16.1.10 baduser@example.com
# python wblist_admin.py --account @mydomain.com --list --whitelist
# python wblist_admin.py --account user@mydomain.com --list --blacklist
python3 wblist_admin.py --account @mydomain.com --list --whitelist
python3 wblist_admin.py --account user@mydomain.com --list --blacklist
```
### Greylisting
@ -212,7 +217,7 @@ For technical details about greylisting, please visit <http://greylisting.org/>
To disable greylisting global, please run command below:
```
python2 /opt/iredapd/tools/greylisting_admin.py --disable --from '@.'
python3 /opt/iredapd/tools/greylisting_admin.py --disable --from '@.'
```
#### General settings
@ -294,67 +299,67 @@ Greylisting is controlled by plugin `greylisting` (file
* List all existing greylisting settings:
```
python greylisting_admin.py --list
python3 greylisting_admin.py --list
```
* List all whitelisted sender domain names (in SQL table `greylisting_whitelist_domains`):
```
python greylisting_admin.py --list-whitelist-domains
python3 greylisting_admin.py --list-whitelist-domains
```
* List all whitelisted sender addresses (in SQL table `greylisting_whitelists`):
```
python greylisting_admin.py --list-whitelists
python3 greylisting_admin.py --list-whitelists
```
* Whitelist IP networks/addresses specified in sender domain:
```
python greylisting_admin.py --whitelist-domain --from '@example.com'
python3 greylisting_admin.py --whitelist-domain --from '@example.com'
```
This is same as:
```
python spf_to_whitelist_domains.py --submit example.com
python3 spf_to_whitelist_domains.py --submit example.com
```
* Remove a whitelisted sender domain:
```
python greylisting_admin.py --remove-whitelist-domain --from '@example.com'
python3 greylisting_admin.py --remove-whitelist-domain --from '@example.com'
```
* Enable greylisting for emails which are sent from anyone to local mail domain `example.com`:
```
python greylisting_admin.py --enable --to '@example.com'
python3 greylisting_admin.py --enable --to '@example.com'
```
* Disable greylisting for emails which are sent from anyone to local mail user `user@example.com`:
```
python greylisting_admin.py --disable --to 'user@example.com'
python3 greylisting_admin.py --disable --to 'user@example.com'
```
* Disable greylisting for emails which are sent from `gmail.com` to local mail user `user@example.com`:
```
python greylisting_admin.py --disable --from '@gmail.com' --to 'user@example.com'
python3 greylisting_admin.py --disable --from '@gmail.com' --to 'user@example.com'
```
* Disable greylisting for sender IP:
```
python greylisting_admin.py --disable --from '45.56.127.226'
python3 greylisting_admin.py --disable --from '45.56.127.226'
```
* Delete greylisting setting for emails which are sent from anyone to local domain `test.com`:
```
python greylisting_admin.py --delete --to '@test.com'
python3 greylisting_admin.py --delete --to '@test.com'
```
##### RECOMMENDED: Additional greylisting whitelist support
@ -382,8 +387,8 @@ To whitelist IP addresses/networks of some mail domain, for example,
`outlook.com`, `microsoft.com`, please run command like below:
```
# cd /opt/iredapd/tools/
# python spf_to_greylist_whitelists.py outlook.com microsoft.com
cd /opt/iredapd/tools/
python3 spf_to_greylist_whitelists.py outlook.com microsoft.com
```
!!! note
@ -404,7 +409,7 @@ without any argument, it will fetch all mail domains stored in sql table
`greylisting_whitelist_domains` instead of fetching from command line arguments.
```
# python spf_to_greylist_whitelists.py
python3 spf_to_greylist_whitelists.py
```
You should setup a cron job to run this script, so that it can keep the IP
@ -412,5 +417,5 @@ addresses/networks up to date. iRedMail sets up the cron job to run every 10 or
30 minutes, like below:
```
*/30 * * * * /usr/bin/python /opt/iredapd/tools/spf_to_greylist_whitelists.py &>/dev/null
*/30 * * * * /usr/bin/python3 /opt/iredapd/tools/spf_to_greylist_whitelists.py &>/dev/null
```

View File

@ -56,6 +56,11 @@
<p>All iRedAPD features listed in current page can be managed with our
web-based admin panel - <a href="https://www.iredmail.org/admin_panel.html">iRedAdmin-Pro</a>.</p>
</div>
<div class="admonition attention">
<p class="admonition-title">Attention</p>
<p>iRedAPD-4.0 and later releases requires Python 3, if you're running
iRedAPD-3.6 or earlier release, please run commands with Python 2 instead.</p>
</div>
<h2 id="introduce-iredapd">Introduce iRedAPD</h2>
<p>iRedAPD is a simple Postfix policy server, written in Python, with plugin
support. It listens on <code>127.0.0.1:7777</code> by default, and runs as a low-privileged
@ -204,25 +209,25 @@ parameter <code>plugins =</code>:</p>
<ul>
<li>Show and add server-wide whitelists or blacklists:</li>
</ul>
<pre><code># python wblist_admin.py --list --whitelist
# python wblist_admin.py --list --blacklist
<pre><code>python3 wblist_admin.py --list --whitelist
python3 wblist_admin.py --list --blacklist
# Whitelist IP address, email address, entire domain, subdomain (including main domain)
# python wblist_admin.py --add --whitelist 192.168.1.10 user@domain.com @iredmail.org @.example.com
python3 wblist_admin.py --add --whitelist 192.168.1.10 user@domain.com @iredmail.org @.example.com
# Blacklist IP address, email address, entire domain, subdomain (including main domain)
# python wblist_admin.py --add --blacklist 202.96.134.133 bad-user@domain.com @bad-domain.com @.sub-domain.com
python3 wblist_admin.py --add --blacklist 202.96.134.133 bad-user@domain.com @bad-domain.com @.sub-domain.com
</code></pre>
<ul>
<li>For per-user or per-domain whitelists and blacklists, please use option
<code>--account</code>. for example:</li>
</ul>
<pre><code># python wblist_admin.py --account @mydomain.com --add --whitelist 192.168.1.10 user@example.com
# python wblist_admin.py --account user@mydomain.com --add --blacklist 172.16.1.10 baduser@example.com
<pre><code>python3 wblist_admin.py --account @mydomain.com --add --whitelist 192.168.1.10 user@example.com
python3 wblist_admin.py --account user@mydomain.com --add --blacklist 172.16.1.10 baduser@example.com
# python wblist_admin.py --account @mydomain.com --list --whitelist
# python wblist_admin.py --account user@mydomain.com --list --blacklist
python3 wblist_admin.py --account @mydomain.com --list --whitelist
python3 wblist_admin.py --account user@mydomain.com --list --blacklist
</code></pre>
<h3 id="greylisting">Greylisting</h3>
@ -233,7 +238,7 @@ parameter <code>plugins =</code>:</p>
<p>For technical details about greylisting, please visit <a href="http://greylisting.org/">http://greylisting.org/</a></p>
<h4 id="how-to-disable-greylisting-service-globally">How to disable greylisting service globally</h4>
<p>To disable greylisting global, please run command below:</p>
<pre><code>python2 /opt/iredapd/tools/greylisting_admin.py --disable --from '@.'
<pre><code>python3 /opt/iredapd/tools/greylisting_admin.py --disable --from '@.'
</code></pre>
<h4 id="general-settings">General settings</h4>
@ -312,65 +317,65 @@ add the settings with custom values in <code>/opt/iredapd/settings.py</code>.</p
<ul>
<li>List all existing greylisting settings:</li>
</ul>
<pre><code>python greylisting_admin.py --list
<pre><code>python3 greylisting_admin.py --list
</code></pre>
<ul>
<li>List all whitelisted sender domain names (in SQL table <code>greylisting_whitelist_domains</code>):</li>
</ul>
<pre><code>python greylisting_admin.py --list-whitelist-domains
<pre><code>python3 greylisting_admin.py --list-whitelist-domains
</code></pre>
<ul>
<li>List all whitelisted sender addresses (in SQL table <code>greylisting_whitelists</code>):</li>
</ul>
<pre><code>python greylisting_admin.py --list-whitelists
<pre><code>python3 greylisting_admin.py --list-whitelists
</code></pre>
<ul>
<li>Whitelist IP networks/addresses specified in sender domain:</li>
</ul>
<pre><code>python greylisting_admin.py --whitelist-domain --from '@example.com'
<pre><code>python3 greylisting_admin.py --whitelist-domain --from '@example.com'
</code></pre>
<p>This is same as:</p>
<pre><code>python spf_to_whitelist_domains.py --submit example.com
<pre><code>python3 spf_to_whitelist_domains.py --submit example.com
</code></pre>
<ul>
<li>Remove a whitelisted sender domain:</li>
</ul>
<pre><code>python greylisting_admin.py --remove-whitelist-domain --from '@example.com'
<pre><code>python3 greylisting_admin.py --remove-whitelist-domain --from '@example.com'
</code></pre>
<ul>
<li>Enable greylisting for emails which are sent from anyone to local mail domain <code>example.com</code>:</li>
</ul>
<pre><code>python greylisting_admin.py --enable --to '@example.com'
<pre><code>python3 greylisting_admin.py --enable --to '@example.com'
</code></pre>
<ul>
<li>Disable greylisting for emails which are sent from anyone to local mail user <code>user@example.com</code>:</li>
</ul>
<pre><code>python greylisting_admin.py --disable --to 'user@example.com'
<pre><code>python3 greylisting_admin.py --disable --to 'user@example.com'
</code></pre>
<ul>
<li>Disable greylisting for emails which are sent from <code>gmail.com</code> to local mail user <code>user@example.com</code>:</li>
</ul>
<pre><code>python greylisting_admin.py --disable --from '@gmail.com' --to 'user@example.com'
<pre><code>python3 greylisting_admin.py --disable --from '@gmail.com' --to 'user@example.com'
</code></pre>
<ul>
<li>Disable greylisting for sender IP:</li>
</ul>
<pre><code>python greylisting_admin.py --disable --from '45.56.127.226'
<pre><code>python3 greylisting_admin.py --disable --from '45.56.127.226'
</code></pre>
<ul>
<li>Delete greylisting setting for emails which are sent from anyone to local domain <code>test.com</code>:</li>
</ul>
<pre><code>python greylisting_admin.py --delete --to '@test.com'
<pre><code>python3 greylisting_admin.py --delete --to '@test.com'
</code></pre>
<h5 id="recommended-additional-greylisting-whitelist-support">RECOMMENDED: Additional greylisting whitelist support</h5>
@ -392,8 +397,8 @@ converted IP addresses/networks defined in SPF/MX records in SQL table
<code>iredapd.greylisting_whitelists</code>.</p>
<p>To whitelist IP addresses/networks of some mail domain, for example,
<code>outlook.com</code>, <code>microsoft.com</code>, please run command like below:</p>
<pre><code># cd /opt/iredapd/tools/
# python spf_to_greylist_whitelists.py outlook.com microsoft.com
<pre><code>cd /opt/iredapd/tools/
python3 spf_to_greylist_whitelists.py outlook.com microsoft.com
</code></pre>
<div class="admonition note">
@ -411,13 +416,13 @@ domain names like above sample.</p>
to store these mail domain names. if you run <code>spf_to_greylist_whitelists.py</code>
without any argument, it will fetch all mail domains stored in sql table
<code>greylisting_whitelist_domains</code> instead of fetching from command line arguments.</p>
<pre><code># python spf_to_greylist_whitelists.py
<pre><code>python3 spf_to_greylist_whitelists.py
</code></pre>
<p>You should setup a cron job to run this script, so that it can keep the IP
addresses/networks up to date. iRedMail sets up the cron job to run every 10 or
30 minutes, like below:</p>
<pre><code>*/30 * * * * /usr/bin/python /opt/iredapd/tools/spf_to_greylist_whitelists.py &amp;&gt;/dev/null
<pre><code>*/30 * * * * /usr/bin/python3 /opt/iredapd/tools/spf_to_greylist_whitelists.py &amp;&gt;/dev/null
</code></pre><div class="footer">
<p style="text-align: center; color: grey;">All documents are available in <a href="https://github.com/iredmail/docs/">GitHub repository</a>, and published under <a href="http://creativecommons.org/licenses/by-nd/3.0/us/" target="_blank">Creative Commons</a> license. You can <a href="https://github.com/iredmail/docs/archive/master.zip">download the latest version</a> for offline reading. If you found something wrong, please do <a href="https://www.iredmail.org/contact.html">contact us</a> to fix it.</p>
</div>