Browse Source

postgresql and postfixadmin

tags/v1.0.0
Robin Thoni 4 years ago
commit
46c15eac59
100 changed files with 7381 additions and 0 deletions
  1. 2
    0
      .gitignore
  2. 2
    0
      README.md
  3. 35
    0
      docker-compose.yml
  4. 35
    0
      postfixadmin/Dockerfile
  5. 59
    0
      postfixadmin/apache2.conf
  6. 52
    0
      postfixadmin/postfixadmin-3.0/ADDITIONS/README.TXT
  7. BIN
      postfixadmin/postfixadmin-3.0/ADDITIONS/change_password.tgz
  8. 112
    0
      postfixadmin/postfixadmin-3.0/ADDITIONS/cleanupdirs.pl
  9. 40
    0
      postfixadmin/postfixadmin-3.0/ADDITIONS/convert-passwd-to-postfixadmin.pl
  10. 8
    0
      postfixadmin/postfixadmin-3.0/ADDITIONS/cyrus/Changelog
  11. 7
    0
      postfixadmin/postfixadmin-3.0/ADDITIONS/cyrus/README-ES.txt
  12. 7
    0
      postfixadmin/postfixadmin-3.0/ADDITIONS/cyrus/README.txt
  13. 36
    0
      postfixadmin/postfixadmin-3.0/ADDITIONS/cyrus/cyrus-mailbox-postcreation.pl
  14. 36
    0
      postfixadmin/postfixadmin-3.0/ADDITIONS/cyrus/cyrus-mailbox-postdelete.pl
  15. 33
    0
      postfixadmin/postfixadmin-3.0/ADDITIONS/cyrus/cyrus-mailbox-postedit.pl
  16. 31
    0
      postfixadmin/postfixadmin-3.0/ADDITIONS/cyrus/cyrus.conf
  17. 77
    0
      postfixadmin/postfixadmin-3.0/ADDITIONS/delete-mailq-by-domain.pl
  18. 141
    0
      postfixadmin/postfixadmin-3.0/ADDITIONS/fetchmail.pl
  19. 231
    0
      postfixadmin/postfixadmin-3.0/ADDITIONS/import_users_from_csv.py
  20. 124
    0
      postfixadmin/postfixadmin-3.0/ADDITIONS/mailbox_remover.pl
  21. 167
    0
      postfixadmin/postfixadmin-3.0/ADDITIONS/mkeveryone.pl
  22. 111
    0
      postfixadmin/postfixadmin-3.0/ADDITIONS/pfa_maildir_cleanup.pl
  23. 62
    0
      postfixadmin/postfixadmin-3.0/ADDITIONS/postfixadmin-domain-postdeletion.sh
  24. 61
    0
      postfixadmin/postfixadmin-3.0/ADDITIONS/postfixadmin-mailbox-postcreation.sh
  25. 77
    0
      postfixadmin/postfixadmin-3.0/ADDITIONS/postfixadmin-mailbox-postdeletion.sh
  26. 151
    0
      postfixadmin/postfixadmin-3.0/ADDITIONS/quota_usage.pl
  27. 38
    0
      postfixadmin/postfixadmin-3.0/ADDITIONS/squirrelmail-plugin/INSTALL
  28. 40
    0
      postfixadmin/postfixadmin-3.0/ADDITIONS/squirrelmail-plugin/LICENSE.txt
  29. 70
    0
      postfixadmin/postfixadmin-3.0/ADDITIONS/squirrelmail-plugin/README
  30. 44
    0
      postfixadmin/postfixadmin-3.0/ADDITIONS/squirrelmail-plugin/common.php
  31. 22
    0
      postfixadmin/postfixadmin-3.0/ADDITIONS/squirrelmail-plugin/config.php.sample
  32. 20
    0
      postfixadmin/postfixadmin-3.0/ADDITIONS/squirrelmail-plugin/debian/README.Debian
  33. 27
    0
      postfixadmin/postfixadmin-3.0/ADDITIONS/squirrelmail-plugin/debian/changelog
  34. 1
    0
      postfixadmin/postfixadmin-3.0/ADDITIONS/squirrelmail-plugin/debian/conffiles
  35. 19
    0
      postfixadmin/postfixadmin-3.0/ADDITIONS/squirrelmail-plugin/debian/control
  36. 11
    0
      postfixadmin/postfixadmin-3.0/ADDITIONS/squirrelmail-plugin/debian/copyright
  37. 4
    0
      postfixadmin/postfixadmin-3.0/ADDITIONS/squirrelmail-plugin/debian/docs
  38. 1
    0
      postfixadmin/postfixadmin-3.0/ADDITIONS/squirrelmail-plugin/debian/files
  39. 3
    0
      postfixadmin/postfixadmin-3.0/ADDITIONS/squirrelmail-plugin/debian/postfixadmin-squirrelmail.dirs
  40. 5
    0
      postfixadmin/postfixadmin-3.0/ADDITIONS/squirrelmail-plugin/debian/postinst
  41. 56
    0
      postfixadmin/postfixadmin-3.0/ADDITIONS/squirrelmail-plugin/debian/rules
  42. 102
    0
      postfixadmin/postfixadmin-3.0/ADDITIONS/squirrelmail-plugin/functions.inc.php
  43. 27
    0
      postfixadmin/postfixadmin-3.0/ADDITIONS/squirrelmail-plugin/index.php
  44. 6
    0
      postfixadmin/postfixadmin-3.0/ADDITIONS/squirrelmail-plugin/locale/build.sh
  45. BIN
      postfixadmin/postfixadmin-3.0/ADDITIONS/squirrelmail-plugin/locale/cs_CZ/LC_MESSAGES/postfixadmin.mo
  46. 132
    0
      postfixadmin/postfixadmin-3.0/ADDITIONS/squirrelmail-plugin/locale/cs_CZ/LC_MESSAGES/postfixadmin.po
  47. BIN
      postfixadmin/postfixadmin-3.0/ADDITIONS/squirrelmail-plugin/locale/da_DK/LC_MESSAGES/postfixadmin.mo
  48. 127
    0
      postfixadmin/postfixadmin-3.0/ADDITIONS/squirrelmail-plugin/locale/da_DK/LC_MESSAGES/postfixadmin.po
  49. BIN
      postfixadmin/postfixadmin-3.0/ADDITIONS/squirrelmail-plugin/locale/de_DE/LC_MESSAGES/postfixadmin.mo
  50. 127
    0
      postfixadmin/postfixadmin-3.0/ADDITIONS/squirrelmail-plugin/locale/de_DE/LC_MESSAGES/postfixadmin.po
  51. BIN
      postfixadmin/postfixadmin-3.0/ADDITIONS/squirrelmail-plugin/locale/hu_HU/LC_MESSAGES/postfixadmin.mo
  52. 135
    0
      postfixadmin/postfixadmin-3.0/ADDITIONS/squirrelmail-plugin/locale/hu_HU/LC_MESSAGES/postfixadmin.po
  53. 129
    0
      postfixadmin/postfixadmin-3.0/ADDITIONS/squirrelmail-plugin/locale/it_IT/LC_MESSAGES/postfixadmin.po
  54. BIN
      postfixadmin/postfixadmin-3.0/ADDITIONS/squirrelmail-plugin/locale/nl_NL/LC_MESSAGES/postfixadmin.mo
  55. 131
    0
      postfixadmin/postfixadmin-3.0/ADDITIONS/squirrelmail-plugin/locale/nl_NL/LC_MESSAGES/postfixadmin.po
  56. BIN
      postfixadmin/postfixadmin-3.0/ADDITIONS/squirrelmail-plugin/locale/pl_PL/LC_MESSAGES/postfixadmin.mo
  57. 132
    0
      postfixadmin/postfixadmin-3.0/ADDITIONS/squirrelmail-plugin/locale/pl_PL/LC_MESSAGES/postfixadmin.po
  58. BIN
      postfixadmin/postfixadmin-3.0/ADDITIONS/squirrelmail-plugin/locale/pt_BR/LC_MESSAGES/postfixadmin.mo
  59. 127
    0
      postfixadmin/postfixadmin-3.0/ADDITIONS/squirrelmail-plugin/locale/pt_BR/LC_MESSAGES/postfixadmin.po
  60. 127
    0
      postfixadmin/postfixadmin-3.0/ADDITIONS/squirrelmail-plugin/po/postfixadmin.po
  61. 128
    0
      postfixadmin/postfixadmin-3.0/ADDITIONS/squirrelmail-plugin/postfixadmin_changepass.php
  62. 165
    0
      postfixadmin/postfixadmin-3.0/ADDITIONS/squirrelmail-plugin/postfixadmin_forward.php
  63. 157
    0
      postfixadmin/postfixadmin-3.0/ADDITIONS/squirrelmail-plugin/postfixadmin_vacation.php
  64. 61
    0
      postfixadmin/postfixadmin-3.0/ADDITIONS/squirrelmail-plugin/setup.php
  65. 2
    0
      postfixadmin/postfixadmin-3.0/ADDITIONS/squirrelmail-plugin/version
  66. 185
    0
      postfixadmin/postfixadmin-3.0/ADDITIONS/virtualmaildel.php
  67. 1015
    0
      postfixadmin/postfixadmin-3.0/CHANGELOG.TXT
  68. 39
    0
      postfixadmin/postfixadmin-3.0/DOCUMENTS/BACKUP_MX.txt
  69. 214
    0
      postfixadmin/postfixadmin-3.0/DOCUMENTS/DOVECOT.txt
  70. 36
    0
      postfixadmin/postfixadmin-3.0/DOCUMENTS/FAQ.txt
  71. 50
    0
      postfixadmin/postfixadmin-3.0/DOCUMENTS/HORDE.txt
  72. 17
    0
      postfixadmin/postfixadmin-3.0/DOCUMENTS/LANGUAGE.txt
  73. 26
    0
      postfixadmin/postfixadmin-3.0/DOCUMENTS/POSTFIXADMIN.txt
  74. 176
    0
      postfixadmin/postfixadmin-3.0/DOCUMENTS/POSTFIX_CONF.txt
  75. 44
    0
      postfixadmin/postfixadmin-3.0/DOCUMENTS/SECURITY.txt
  76. 16
    0
      postfixadmin/postfixadmin-3.0/DOCUMENTS/SUPERADMIN.txt
  77. 111
    0
      postfixadmin/postfixadmin-3.0/DOCUMENTS/UPGRADE.txt
  78. 2
    0
      postfixadmin/postfixadmin-3.0/DOCUMENTS/screenshots/README.txt
  79. BIN
      postfixadmin/postfixadmin-3.0/DOCUMENTS/screenshots/postfixadmin-admin-create-alias.jpg
  80. BIN
      postfixadmin/postfixadmin-3.0/DOCUMENTS/screenshots/postfixadmin-admin-create-domain.jpg
  81. BIN
      postfixadmin/postfixadmin-3.0/DOCUMENTS/screenshots/postfixadmin-admin-create-mailbox.jpg
  82. BIN
      postfixadmin/postfixadmin-3.0/DOCUMENTS/screenshots/postfixadmin-admin-domain-list.jpg
  83. BIN
      postfixadmin/postfixadmin-3.0/DOCUMENTS/screenshots/postfixadmin-admin-virtual-list.jpg
  84. BIN
      postfixadmin/postfixadmin-3.0/DOCUMENTS/screenshots/postfixadmin-inital-welcome.jpg
  85. BIN
      postfixadmin/postfixadmin-3.0/DOCUMENTS/screenshots/postfixadmin-mail-admin-login.jpg
  86. BIN
      postfixadmin/postfixadmin-3.0/DOCUMENTS/screenshots/postfixadmin-user-change-forward.jpg
  87. BIN
      postfixadmin/postfixadmin-3.0/DOCUMENTS/screenshots/postfixadmin-user-overview.jpg
  88. BIN
      postfixadmin/postfixadmin-3.0/DOCUMENTS/screenshots/postfixadmin-user-vacation.jpg
  89. 281
    0
      postfixadmin/postfixadmin-3.0/GPL-LICENSE.TXT
  90. 159
    0
      postfixadmin/postfixadmin-3.0/INSTALL.TXT
  91. 46
    0
      postfixadmin/postfixadmin-3.0/LICENSE.TXT
  92. 512
    0
      postfixadmin/postfixadmin-3.0/VIRTUAL_VACATION/FILTER_README
  93. 222
    0
      postfixadmin/postfixadmin-3.0/VIRTUAL_VACATION/INSTALL.TXT
  94. 22
    0
      postfixadmin/postfixadmin-3.0/VIRTUAL_VACATION/index.php
  95. 22
    0
      postfixadmin/postfixadmin-3.0/VIRTUAL_VACATION/tests/asterisk-email.txt
  96. 55
    0
      postfixadmin/postfixadmin-3.0/VIRTUAL_VACATION/tests/facebook.txt
  97. 43
    0
      postfixadmin/postfixadmin-3.0/VIRTUAL_VACATION/tests/mail-myself.txt
  98. 110
    0
      postfixadmin/postfixadmin-3.0/VIRTUAL_VACATION/tests/mailing-list.txt
  99. 105
    0
      postfixadmin/postfixadmin-3.0/VIRTUAL_VACATION/tests/spam.txt
  100. 0
    0
      postfixadmin/postfixadmin-3.0/VIRTUAL_VACATION/tests/teodor-smtp-envelope-headers.txt

+ 2
- 0
.gitignore View File

@@ -0,0 +1,2 @@
1
+*.swp
2
+/data/postgresql/data

+ 2
- 0
README.md View File

@@ -0,0 +1,2 @@
1
+postfixadmin default admin:
2
+root@example.org:toor42

+ 35
- 0
docker-compose.yml View File

@@ -0,0 +1,35 @@
1
+version: '2'
2
+
3
+services:
4
+    database:
5
+        build: ./postgresql
6
+        container_name: mx-postgresql
7
+        networks:
8
+            internal.docker:
9
+                aliases:
10
+                    - postgresql.internal.docker
11
+        volumes:
12
+            - ./data/postgresql/data:/var/lib/postgresql/data
13
+        ports:
14
+            - "34000:5432"
15
+        environment:
16
+            - POSTGRES_USER=postfixadmin
17
+            - POSTGRES_PASSWORD=pg_password
18
+
19
+    postfixadmin:
20
+        build: ./postfixadmin
21
+        container_name: mx-postfixadmin
22
+        networks:
23
+            internal.docker:
24
+                aliases:
25
+                    - postfixadmin.internal.docker
26
+        ports:
27
+            - "34001:80"
28
+        environment:
29
+            - DB_HOST=postgresql.internal.docker
30
+            - DB_USER=postfixadmin
31
+            - DB_PASSWORD=pg_password
32
+            - DB_DB=postfixadmin
33
+
34
+networks:
35
+    internal.docker:

+ 35
- 0
postfixadmin/Dockerfile View File

@@ -0,0 +1,35 @@
1
+FROM debian:jessie
2
+
3
+# FROM https://github.com/ZHAJOR/Docker-Apache-2.4-Php-5.6-for-Laravel
4
+MAINTAINER Robin Thoni <robin@rthoni.com>
5
+
6
+COPY run.sh /run.sh
7
+
8
+RUN apt-get update && apt-get -y install\
9
+        apache2=2.4.*\
10
+        libapache2-mod-php5\
11
+        php5\
12
+        php5-mcrypt\
13
+        php5-pgsql\
14
+        php5-mysql\
15
+        php5-gd\
16
+        php5-curl\
17
+        php5-imap &&\
18
+        apt-get clean &&\
19
+        /usr/sbin/a2enmod rewrite &&\
20
+        rm -rf /var/www/html &&\
21
+        mkdir -p /var/lock/apache2 /var/run/apache2 /var/log/apache2 /var/www/html &&\
22
+        chown -R www-data:www-data /var/lock/apache2 /var/run/apache2 /var/log/apache2 /var/www/html &&\
23
+        chmod -v +x /run.sh &&\
24
+        ln -sf /dev/stderr /var/log/apache2/error.log &&\
25
+        ln -sf /dev/stdout /var/log/apache2/access.log
26
+
27
+COPY apache2.conf /etc/apache2/apache2.conf
28
+
29
+EXPOSE 80
30
+
31
+COPY ./postfixadmin-3.0/ /var/www/html/
32
+RUN chmod -R 777 /var/www/html/templates_c
33
+#VOLUME ["/var/www/html"]
34
+
35
+CMD ["/run.sh"]

+ 59
- 0
postfixadmin/apache2.conf View File

@@ -0,0 +1,59 @@
1
+# see http://sources.debian.net/src/apache2/2.4.10-1/debian/config-dir/apache2.conf
2
+
3
+Mutex file:/var/lock/apache2 default
4
+PidFile /var/run/apache2/apache2.pid
5
+Timeout 300
6
+KeepAlive On
7
+MaxKeepAliveRequests 100
8
+KeepAliveTimeout 5
9
+User www-data
10
+Group www-data
11
+HostnameLookups Off
12
+ErrorLog /var/log/apache2/error.log
13
+LogLevel warn
14
+
15
+IncludeOptional mods-enabled/*.load
16
+IncludeOptional mods-enabled/*.conf
17
+
18
+# ports.conf
19
+Listen 80
20
+<IfModule ssl_module>
21
+    Listen 443
22
+</IfModule>
23
+<IfModule mod_gnutls.c>
24
+    Listen 443
25
+</IfModule>
26
+
27
+DocumentRoot "/var/www/html/"
28
+
29
+<Directory />
30
+    Options FollowSymLinks
31
+    AllowOverride None
32
+    Require all denied
33
+</Directory>
34
+
35
+<Directory /var/www/html/>
36
+    Options FollowSymLinks
37
+    AllowOverride All
38
+    Require all granted
39
+</Directory>
40
+
41
+
42
+
43
+LogFormat "%v:%p %h %l %u %t \"%r\" %>s %O \"%{Referer}i\" \"%{User-Agent}i\"" vhost_combined
44
+LogFormat "%h %l %u %t \"%r\" %>s %O \"%{Referer}i\" \"%{User-Agent}i\"" combined
45
+LogFormat "%h %l %u %t \"%r\" %>s %O" common
46
+LogFormat "%{Referer}i -> %U" referer
47
+LogFormat "%{User-agent}i" agent
48
+
49
+CustomLog /var/log/apache2/access.log combined
50
+
51
+<FilesMatch \.php$>
52
+    SetHandler application/x-httpd-php
53
+</FilesMatch>
54
+
55
+# Multiple DirectoryIndex directives within the same context will add
56
+# to the list of resources to look for rather than replace
57
+# https://httpd.apache.org/docs/current/mod/mod_dir.html#directoryindex
58
+DirectoryIndex disabled
59
+DirectoryIndex index.php index.html

+ 52
- 0
postfixadmin/postfixadmin-3.0/ADDITIONS/README.TXT View File

@@ -0,0 +1,52 @@
1
+#
2
+# Postfix Admin ADDITIONS
3
+#
4
+
5
+BEFORE YOU START
6
+----------------
7
+
8
+**** ALL THESE SCRIPTS ARE CREATED BY THIRD PARTIES ****
9
+     **** THEY ARE AS IS, USE AT YOUR OWN RISK! ****
10
+
11
+ADDITIONS
12
+---------
13
+
14
+In this directory you will find additional scripts that are build by others.
15
+
16
+- change_password.tgz
17
+by George Vieira <george at citadelcomputer dot com dot au>
18
+SquirrelMail plugin to change your passwor
19
+
20
+- cleanupdirs.pl
21
+by jared bell <jared at beol dot net>
22
+Displays a list of mailboxes that need to be deleted
23
+
24
+- mailbox_remover.pl
25
+by Petr Znojemsky
26
+Deletes all unused mailboxes
27
+
28
+- mkeveryone.pl
29
+by Joshua Preston
30
+Generate an 'everybody' alias for a domain.
31
+
32
+- pfa_maildir_cleanup.pl
33
+by Stephen Fulton <sfulton at esoteric dot ca>
34
+Deletes all unused mailboxes
35
+
36
+- postfixadmin-0.3-1.4.tar.gz
37
+by Florian Kimmerl <info at spacekoeln dot de>
38
+The Postfixadmin SquirrelMail plugin let users change their virtual alias,
39
+vacation status/message and password.
40
+
41
+- virtualmaildel.php
42
+by George Vieira <george at citadelcomputer dot com dot au>
43
+Deletes all unused mailboxes
44
+
45
+- postfixadmin-mailbox-postcreation.sh
46
+- postfixadmin-mailbox-postdeletion.sh
47
+- postfixadmin-domain-postdeletion.sh
48
+by Troels Arvin <troels@arvin.dk>
49
+Examples of scripts relevant to the optional 
50
+$CONF['mailbox_postcreation_script'],
51
+$CONF['mailbox_postdeletion_script'] and
52
+$CONF['domain_postdeletion_script']  configuration options.

BIN
postfixadmin/postfixadmin-3.0/ADDITIONS/change_password.tgz View File


+ 112
- 0
postfixadmin/postfixadmin-3.0/ADDITIONS/cleanupdirs.pl View File

@@ -0,0 +1,112 @@
1
+#!/usr/bin/perl -w
2
+
3
+################################################################################
4
+#
5
+# cleanupdirs 1.2 by jared bell <jared@beol.net>
6
+#
7
+# display/remove maildir & domains directory tree's not listed in the postfix
8
+# mysql database. currently setup for use with postfixadmin, but can be
9
+# adapted. edit settings where it says 'change settings as needed.' by default
10
+# this program will display a list of directories which need deleted, nothing
11
+# is actually deleted. to change this behavior, look into the command line
12
+# arguments.
13
+#
14
+# command line arguments:
15
+#   --delete
16
+#       force automatic deletion of directories. instead of displaying a list
17
+#       of deleted directories, they will be logged in the specified logfile.
18
+#   --print
19
+#       display deleted directories as well as log them. only valid when
20
+#       '--delete' has been specified.
21
+#
22
+# settings:
23
+#   $root_path = "/home/vmail";
24
+#       if maildir is '/home/vmail/domain.tld/user' then '/home/vmail' is the
25
+#       $root_path. if your maildirs are '/home/vmail/user@domain.tld' then
26
+#       this program will need to be modified in order to work right.
27
+#   $logfile = "/var/log/removed_maildirs.log";
28
+#       the logfile to use when $delete_old_dirs is set to 1
29
+#   $db_* = "*";
30
+#       sets the host, port, database, user and pass to your mysql server
31
+#
32
+# version history:
33
+#   1.2 - removed uneeded settings. added '--print' command line argument
34
+#   1.1 - added '--delete' command line argument
35
+#   1.0 - initial release
36
+#
37
+################################################################################
38
+
39
+use strict;
40
+use DBI;
41
+use File::Path;
42
+use Getopt::Long;
43
+
44
+### change settings as needed, see notes above #################################
45
+our $root_path = "/home/vmail";
46
+our $logfile = "/var/log/removed_maildirs.log";
47
+our $db_hostname = "localhost";
48
+our $db_port = "3306"; # this script currently supports MySQL only
49
+our $db_database = "postfix";
50
+our $db_username = "someuser";
51
+our $db_password = "somepass";
52
+
53
+# instead of changing this script, you can put your settings to /etc/mail/postfixadmin/cleanupdirs.conf
54
+# just use perl syntax there to fill the variables listed above (without the "our" keyword). Example:
55
+# $db_username = 'mail';
56
+if (-f "/etc/mail/postfixadmin/cleanupdirs.conf") {
57
+	require "/etc/mail/postfixadmin/cleanupdirs.conf";
58
+}
59
+
60
+################################################################################
61
+
62
+### begin program ##############################################################
63
+my(@dirs_to_delete, $logfile_open);
64
+my $delete_old_dirs = 0; # do not delete by default, use cmdline to change this
65
+my $print_also = 0; # also print items when deleting, use cmdline to change this
66
+GetOptions ('delete' => \$delete_old_dirs, 'print' => \$print_also);
67
+my $conn_info = "DBI:mysql:database=$db_database;hostname=$db_hostname;port=$db_port";
68
+my $dbh = DBI->connect($conn_info, $db_username, $db_password)
69
+  or die $DBI::errstr;
70
+opendir DOMAINDIR, $root_path
71
+  or die "Unable to access directory '$root_path' ($!)";
72
+foreach my $domain_dir (sort readdir DOMAINDIR) {
73
+  next if $domain_dir =~ /^\./; # skip dotted dirs
74
+  next if (! -d "$root_path/$domain_dir"); # skip everything that is not a directory
75
+  my $full_domain_dir = "$root_path/$domain_dir";
76
+  opendir USERDIR, $full_domain_dir
77
+    or die "Unable to access directory '$full_domain_dir' ($!)";
78
+  foreach my $user_dir (sort readdir USERDIR) {
79
+    next if $user_dir =~ /^\./; # skip dotted dirs
80
+    push @dirs_to_delete, "$full_domain_dir/$user_dir"
81
+      if &check_dir("SELECT maildir FROM mailbox WHERE maildir = ?",
82
+        "$domain_dir/$user_dir/"); # end slash needed for checkdir
83
+  }
84
+  push @dirs_to_delete, $full_domain_dir
85
+    if &check_dir("SELECT domain FROM domain WHERE domain = ?", $domain_dir);
86
+}
87
+closedir USERDIR;
88
+closedir DOMAINDIR;
89
+$dbh->disconnect;
90
+if (@dirs_to_delete) {
91
+  foreach my $to_delete (@dirs_to_delete) {
92
+    if ($delete_old_dirs == 1) {
93
+      $logfile_open = open LOGFILE, ">> $logfile"
94
+        or die "Unable to append logfile '$logfile' ($!)"
95
+          unless $logfile_open;
96
+      rmtree $to_delete;
97
+      print LOGFILE localtime() . " Deleting directory '$to_delete'\n";
98
+      print localtime() . " Deleting directory '$to_delete'\n"
99
+        if $print_also;
100
+    } else {
101
+      print localtime() . " Need to delete directory '$to_delete'\n";
102
+    }
103
+  }
104
+}
105
+close LOGFILE if $logfile_open;
106
+sub check_dir {
107
+  my($query, $dir) = @_;
108
+  my $sth = $dbh->prepare($query);
109
+  my $num_rows = $sth->execute($dir);
110
+  $sth->finish;
111
+  ($num_rows eq "0E0") ? 1 : 0;
112
+}

+ 40
- 0
postfixadmin/postfixadmin-3.0/ADDITIONS/convert-passwd-to-postfixadmin.pl View File

@@ -0,0 +1,40 @@
1
+#!/usr/bin/perl -w
2
+#
3
+# Postfix Admin 
4
+# 
5
+# LICENSE 
6
+# This source file is subject to the GPL license that is bundled with  
7
+# this package in the file LICENSE.TXT. 
8
+# 
9
+# Further details on the project are available at http://postfixadmin.sf.net 
10
+# 
11
+# @version $Id: convert-passwd-to-postfixadmin.pl 1558 2013-11-10 15:57:32Z christian_boltz $ 
12
+# @license GNU GPL v2 or later. 
13
+#
14
+#
15
+# Really crude attempt at taking all users from a local 
16
+# passwd file (/etc/shadow) and creating postfixadmin mailboxes for them.
17
+#
18
+# The script outputs some SQL, which you need to then insert into your database
19
+# as appropriate.
20
+#
21
+# Notes:
22
+#  1) Change $mydomain and $true as required.
23
+#  2) Ideally it should parse /etc/passwd, or call the getpw()? function and
24
+#     populate someone's name if known.
25
+#  3) There's plenty of room for improvement.
26
+#
27
+# Original author: David Goodwin <david at palepurple-co-uk> - 2007/10/05.
28
+#
29
+use strict;
30
+
31
+open(FH, '</etc/shadow') or die ('Cannot open shadow file; you need to be root - ' . $!);
32
+my $mydomain = "test.com";
33
+my $true = "t"; # t for pgsql; 1 for mysql
34
+foreach(<FH>) { 
35
+    my ($username, $password) = split(':', $_);
36
+    next if $password eq '!';
37
+    next if $password eq '*';
38
+    my $maildir = "$username\@$mydomain/";
39
+    print "insert into mailbox (username, password, domain, active, maildir) values ('$username', '$password', '$mydomain', $true, '$maildir');\n";
40
+}

+ 8
- 0
postfixadmin/postfixadmin-3.0/ADDITIONS/cyrus/Changelog View File

@@ -0,0 +1,8 @@
1
+
2
+Version 0.1 -- 26/10/2009
3
+---------------------------
4
+
5
+  * Public Release.
6
+  * Postcreation, Postdeletion and Postedit hooks.
7
+
8
+

+ 7
- 0
postfixadmin/postfixadmin-3.0/ADDITIONS/cyrus/README-ES.txt View File

@@ -0,0 +1,7 @@
1
+
2
+Configuración
3
+-------------
4
+
5
+ - Edita el fichero cyrus.conf y modifica las variables $cyrus_*. El usuario debe tener permisos sobre todas las cuentas.
6
+ - Edita los ficheros cyrus-*.pl y cambia la ruta de cyrus.conf (linea require '/path/to/cyrus.conf';)
7
+

+ 7
- 0
postfixadmin/postfixadmin-3.0/ADDITIONS/cyrus/README.txt View File

@@ -0,0 +1,7 @@
1
+
2
+Configuration
3
+-------------
4
+
5
+ - Edit cyrus.conf and set $cyrus_* variables correctly. User must have permission over all accounts.
6
+ - Edit cyrus-*.pl and change path to cyrus.conf (require '/path/to/cyrus.conf'; line)
7
+

+ 36
- 0
postfixadmin/postfixadmin-3.0/ADDITIONS/cyrus/cyrus-mailbox-postcreation.pl View File

@@ -0,0 +1,36 @@
1
+#!/usr/bin/perl 
2
+
3
+# Cyrus Mailbox creation
4
+#
5
+# Iñaki Rodriguez (irodriguez@virtualminds.es / irodriguez@ackstorm.es)
6
+# 
7
+#  LICENSE
8
+#  This source file is subject to the GPL license that is bundled with
9
+#  this package in the file LICENSE.TXT.
10
+#
11
+# (26/10/2009) 
12
+
13
+use Cyrus::IMAP::Admin;
14
+require '/etc/mail/postfixadmin/cyrus.conf';
15
+use strict;
16
+use vars qw($cyrus_user $cyrus_password $cyrus_host);
17
+
18
+my %opts;
19
+
20
+my $mailbox = mailbox_name($ARGV[0]);
21
+
22
+my $client = Cyrus::IMAP::Admin->new($cyrus_host);
23
+die_on_error($client);
24
+
25
+$opts{-user} = $cyrus_user;
26
+$opts{-password} = $cyrus_password;
27
+
28
+$client->authenticate(%opts);
29
+die_on_error($client);
30
+
31
+$client->create($mailbox);
32
+die_on_error($client);
33
+
34
+$client->setquota($mailbox,'STORAGE',scalar $ARGV[3]) if ($ARGV[3] > 0);
35
+die_on_error($client);
36
+

+ 36
- 0
postfixadmin/postfixadmin-3.0/ADDITIONS/cyrus/cyrus-mailbox-postdelete.pl View File

@@ -0,0 +1,36 @@
1
+#!/usr/bin/perl 
2
+
3
+# Cyrus Mailbox deletion
4
+#
5
+# Iñaki Rodriguez (irodriguez@virtualminds.es / irodriguez@ackstorm.es)
6
+# 
7
+#  LICENSE
8
+#  This source file is subject to the GPL license that is bundled with
9
+#  this package in the file LICENSE.TXT.
10
+#
11
+# (26/10/2009) 
12
+
13
+use Cyrus::IMAP::Admin;
14
+require '/etc/mail/postfixadmin/cyrus.conf';
15
+use strict;
16
+use vars qw($cyrus_user $cyrus_password $cyrus_host);
17
+
18
+my %opts;
19
+
20
+my $mailbox = mailbox_name($ARGV[0]);
21
+
22
+my $client = Cyrus::IMAP::Admin->new($cyrus_host);
23
+die_on_error($client);
24
+
25
+$opts{-user} = $cyrus_user;
26
+$opts{-password} = $cyrus_password;
27
+
28
+$client->authenticate(%opts);
29
+die_on_error($client);
30
+
31
+$client->setacl($mailbox,$cyrus_user => 'all');
32
+die_on_error($client);
33
+
34
+$client->deletemailbox($mailbox);
35
+die_on_error($client);
36
+

+ 33
- 0
postfixadmin/postfixadmin-3.0/ADDITIONS/cyrus/cyrus-mailbox-postedit.pl View File

@@ -0,0 +1,33 @@
1
+#!/usr/bin/perl 
2
+
3
+# Cyrus Mailbox edition
4
+#
5
+# Iñaki Rodriguez (irodriguez@virtualminds.es / irodriguez@ackstorm.es)
6
+#
7
+#  LICENSE
8
+#  This source file is subject to the GPL license that is bundled with
9
+#  this package in the file LICENSE.TXT.
10
+#
11
+# (26/10/2009)
12
+
13
+use Cyrus::IMAP::Admin;
14
+require '/etc/mail/postfixadmin/cyrus.conf';
15
+use strict;
16
+use vars qw($cyrus_user $cyrus_password $cyrus_host);
17
+
18
+my %opts;
19
+
20
+my $mailbox = mailbox_name($ARGV[0]);
21
+
22
+my $client = Cyrus::IMAP::Admin->new($cyrus_host);
23
+die_on_error($client);
24
+
25
+$opts{-user} = $cyrus_user;
26
+$opts{-password} = $cyrus_password;
27
+
28
+$client->authenticate(%opts);
29
+die_on_error($client);
30
+
31
+$client->setquota($mailbox,'STORAGE',scalar $ARGV[3]) if ($ARGV[3] > 0);
32
+die_on_error($client);
33
+

+ 31
- 0
postfixadmin/postfixadmin-3.0/ADDITIONS/cyrus/cyrus.conf View File

@@ -0,0 +1,31 @@
1
+#!/usr/bin/perl
2
+
3
+# Config
4
+
5
+$cyrus_user = 		'cyrus';
6
+$cyrus_password =	'cyruspass';
7
+$cyrus_host =		'localhost';
8
+
9
+# unixhierarchysep => 1 (yes) / 0 (no)
10
+$unixhierarchysep =	1;
11
+
12
+# Common routines
13
+
14
+sub mailbox_name {
15
+	my $mailbox = shift;
16
+	
17
+	if($unixhierarchysep) {
18
+	        $mailbox = 'user/'.$ARGV[0];
19
+	} else {
20
+        	$mailbox = 'user.'.$ARGV[0];
21
+	}
22
+
23
+	return $mailbox;
24
+}
25
+
26
+sub die_on_error {
27
+	my $cyradm = shift;
28
+	if($cyradm->error) { die $cyradm->error; }
29
+}
30
+1;
31
+

+ 77
- 0
postfixadmin/postfixadmin-3.0/ADDITIONS/delete-mailq-by-domain.pl View File

@@ -0,0 +1,77 @@
1
+#!/usr/bin/perl
2
+
3
+
4
+use strict;
5
+use warnings;
6
+use Getopt::Long;
7
+
8
+
9
+$ENV{'PATH'} = "/sbin:/bin:/usr/sbin:/usr/bin";
10
+
11
+my ($domain);
12
+my $list = 0;
13
+
14
+(help()) if (!$ARGV[0]);
15
+GetOptions ('l' => \$list, 'd=s' => \$domain) or (help());
16
+
17
+
18
+(list_queue()) if ($list == 1);
19
+
20
+(delete_queue()) if ($domain);
21
+
22
+
23
+sub delete_queue {
24
+my $ids = `postqueue -p`;
25
+my @ids = split /\n/, $ids;
26
+
27
+for my $id (@ids) {
28
+        next if $id =~ /^[\s\(-]/;
29
+        chomp $id;
30
+        next unless $id;
31
+        $id =~ s/(.*?)\**\s.*/$1/;
32
+        #print "$id\n";
33
+        my $match = `postcat -q $id | grep '$domain'`;
34
+        next unless $match;
35
+        #print "Deleting ID: $id\n";
36
+        my $saida = `postsuper -d $id`;
37
+        print $saida;
38
+}
39
+
40
+}
41
+
42
+
43
+
44
+
45
+sub list_queue {
46
+my %hash_mail = ();
47
+my @queue = `postqueue -p`;
48
+my($queue,$key,$total);
49
+
50
+
51
+foreach $queue(@queue) {
52
+        chomp $queue;
53
+        if ( $queue =~ /^\s+.*\@(.*)/ ) {
54
+                $hash_mail{$1}++;
55
+        }
56
+}
57
+print"\nTOTAL\tTO\n";
58
+print"-----
59
+----------------------------------------------------------------\n";
60
+foreach $key (reverse sort { $hash_mail{$a} <=> $hash_mail{$b}} keys
61
+%hash_mail) {
62
+        $total += $hash_mail{$key};
63
+        print"$hash_mail{$key} - $key\n";
64
+}
65
+print"\n$total -> TOTAL QUEUE\n";
66
+
67
+}
68
+
69
+
70
+sub help {
71
+print "Usage $0 -l	            To list a row of E-mail
72
+Usage $0 -d domain.com   To delete the mensgens the Domain\n"; 
73
+}
74
+
75
+
76
+
77
+

+ 141
- 0
postfixadmin/postfixadmin-3.0/ADDITIONS/fetchmail.pl View File

@@ -0,0 +1,141 @@
1
+#!/usr/bin/perl
2
+
3
+use DBI;
4
+use MIME::Base64;
5
+# use Data::Dumper;
6
+use File::Temp qw/ mkstemp /;
7
+use Sys::Syslog;
8
+# require liblockfile-simple-perl
9
+use LockFile::Simple qw(lock trylock unlock);
10
+
11
+######################################################################
12
+########## Change the following variables to fit your needs ##########
13
+
14
+# database settings
15
+
16
+# database backend - uncomment one of these
17
+our $db_type = 'Pg';
18
+#my $db_type = 'mysql';
19
+
20
+# host name
21
+our $db_host="127.0.0.1";
22
+# database name
23
+our $db_name="postfix";
24
+# database username
25
+our $db_username="mail";
26
+# database password
27
+our $db_password="CHANGE_ME!";
28
+
29
+# instead of changing this script, you can put your settings to /etc/mail/postfixadmin/fetchmail.conf
30
+# just use perl syntax there to fill the variables listed above (without the "our" keyword). Example:
31
+# $db_username = 'mail';
32
+if (-f "/etc/mail/postfixadmin/fetchmail.conf") {
33
+	require "/etc/mail/postfixadmin/fetchmail.conf";
34
+}
35
+
36
+
37
+#################### Don't change anything below! ####################
38
+######################################################################
39
+
40
+openlog("fetchmail-all", "pid", "mail");
41
+
42
+sub log_and_die {
43
+	my($message) = @_;
44
+  syslog("err", $message);
45
+  die $message;
46
+}
47
+
48
+# read options and arguments
49
+
50
+$configfile = "/etc/fetchmail-all/config";
51
+
52
+@ARGS1 = @ARGV;
53
+
54
+while ($_ = shift @ARGS1) {
55
+    if (/^-/) {
56
+        if (/^--config$/) {
57
+            $configfile = shift @ARGS1
58
+        }
59
+    }
60
+}
61
+
62
+$run_dir="/var/run/fetchmail";
63
+
64
+# use specified config file
65
+if (-e $configfile) {
66
+    do $configfile;
67
+}
68
+
69
+if($db_type eq "Pg" || $db_type eq "mysql") {
70
+	$dsn = "DBI:$db_type:database=$db_name;host=$db_host";
71
+} else {
72
+	log_and_die "unsupported db_type $db_type";
73
+}
74
+
75
+$lock_file=$run_dir . "/fetchmail-all.lock";
76
+
77
+$lockmgr = LockFile::Simple->make(-autoclean => 1, -max => 1);
78
+$lockmgr->lock($lock_file) || log_and_die "can't lock ${lock_file}";
79
+
80
+# database connect
81
+$dbh = DBI->connect($dsn, $db_username, $db_password) || log_and_die "cannot connect the database";
82
+
83
+if($db_type eq "Pg") {
84
+	$sql_cond = "active = 't' AND date_part('epoch',now())-date_part('epoch',date)";
85
+} elsif($db_type eq "mysql") {
86
+	$sql_cond = "active = 1 AND unix_timestamp(now())-unix_timestamp(date)";
87
+}
88
+
89
+$sql = "
90
+	SELECT id,mailbox,src_server,src_auth,src_user,src_password,src_folder,fetchall,keep,protocol,mda,extra_options,usessl, sslcertck, sslcertpath, sslfingerprint
91
+	FROM fetchmail
92
+	WHERE $sql_cond  > poll_time*60
93
+	";
94
+
95
+my (%config);
96
+map{
97
+	my ($id,$mailbox,$src_server,$src_auth,$src_user,$src_password,$src_folder,$fetchall,$keep,$protocol,$mda,$extra_options,$usessl,$sslcertck,$sslcertpath,$sslfingerprint)=@$_;
98
+
99
+	syslog("info","fetch ${src_user}@${src_server} for ${mailbox}");
100
+
101
+	$cmd="user '${src_user}' there with password '".decode_base64($src_password)."'";
102
+	$cmd.=" folder '${src_folder}'" if ($src_folder);
103
+	$cmd.=" mda ".$mda if ($mda);
104
+
105
+#	$cmd.=" mda \"/usr/local/libexec/dovecot/deliver -m ${mailbox}\"";
106
+	$cmd.=" is '${mailbox}' here";
107
+
108
+	$cmd.=" keep" if ($keep);
109
+	$cmd.=" fetchall" if ($fetchall);
110
+	$cmd.=" ssl" if ($usessl);
111
+	$cmd.=" sslcertck" if($sslcertck);
112
+	$cmd.=" sslcertpath $sslcertpath" if ($sslcertck && $sslcertpath);
113
+	$cmd.=" sslfingerprint \"$sslfingerprint\"" if ($sslfingerprint);
114
+	$cmd.=" ".$extra_options if ($extra_options);
115
+
116
+	$text=<<TXT;
117
+set postmaster "postmaster"
118
+set nobouncemail
119
+set no spambounce
120
+set properties ""
121
+set syslog
122
+
123
+poll ${src_server} with proto ${protocol}
124
+	$cmd
125
+
126
+TXT
127
+
128
+  ($file_handler, $filename) = mkstemp( "/tmp/fetchmail-all-XXXXX" ) or log_and_die "cannot open/create fetchmail temp file";
129
+  print $file_handler $text;
130
+  close $file_handler;
131
+
132
+  $ret=`/usr/bin/fetchmail -f $filename -i $run_dir/fetchmail.pid`;
133
+
134
+  unlink $filename;
135
+
136
+  $sql="UPDATE fetchmail SET returned_text=".$dbh->quote($ret).", date=now() WHERE id=".$id;
137
+  $dbh->do($sql);
138
+}@{$dbh->selectall_arrayref($sql)};
139
+
140
+$lockmgr->unlock($lock_file);
141
+closelog();

+ 231
- 0
postfixadmin/postfixadmin-3.0/ADDITIONS/import_users_from_csv.py View File

@@ -0,0 +1,231 @@
1
+#!/usr/bin/env python
2
+# -*- coding: utf-8 -*-
3
+# Script takes a CSV list of users and does a 'bulk' insertion into mysql.
4
+#
5
+# Copyright (C) 2009 Simone Piccardi
6
+#
7
+# This program is free software; you can redistribute it and/or modify
8
+# it under the terms of the GNU General Public License as published by
9
+# the Free Software Foundation; either version 2 of the License, or (at
10
+# your option) any later version.
11
+#
12
+# This program is distributed in the hope that it will be useful, but
13
+# WITHOUT ANY WARRANTY; without even the implied warranty of
14
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
15
+# General Public License for more details.
16
+#
17
+# You should have received a copy of the GNU General Public License
18
+# along with this program; if not, write to the Free Software
19
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
20
+#
21
+
22
+import csv
23
+import getopt
24
+import sys
25
+import re
26
+import time
27
+import random, string
28
+from datetime import datetime
29
+from crypt import crypt
30
+try:
31
+    import MySQLdb 
32
+except ImportError ,e:
33
+    print 'Cannot import the needed MySQLdb module, you must install it'
34
+    print 'on Debian systems just use the command'
35
+    print '   apt-get install python-mysqldb'
36
+
37
+def usage():
38
+    print "Usage: inspostadmusers.py [options] users.csv"
39
+    print "       -h        print this help"
40
+    print "       -t        test run, do not insert, just print"
41
+    print "       -u        DB user"
42
+    print "       -p        DB password"
43
+    print "       -D        DB name"
44
+    print "       -H        DB host"
45
+    print "       -q        Quota in Mb (0 => no limit)"
46
+    print "       -n        char in seed"
47
+    print "       -d        debug info on"
48
+    print "       -A        create default alias for each domain"
49
+    print
50
+    print "the users.csv file must contains the user list with a line"
51
+    print "for each user, first line should be a title line with at least"
52
+    print "the following column names: "
53
+    print " * user     - user part of the email (like user in user@domain.com)"
54
+    print " * password - cleartext password"
55
+    print " * domain   - domain name (like 'domain.com')"
56
+    print " * name     - full user name ('Name Surname')"
57
+    print
58
+    print "the 'name' column is optional, other columns will be ignored"
59
+    print
60
+    print "Known restrictions:"
61
+    print "* this script only works with MySQL"
62
+    print "* mailbox paths are hardcoded to domain/username/"
63
+
64
+
65
+# option parsing
66
+try:
67
+    opts, args = getopt.getopt(sys.argv[1:], 'u:p:d:D:H:htdA')
68
+    optval={}
69
+    for opt, val in opts:
70
+        if opt == "-h":
71
+            usage()
72
+            sys.exit(0)
73
+        else:
74
+            optval[opt]=val
75
+except getopt.GetoptError:
76
+    usage()
77
+    sys.exit(2)
78
+
79
+#
80
+# Setup DB connection
81
+#
82
+MYSQLDB="postfixadmin"
83
+MYSQLUSER="postfixadmin"
84
+MYSQLPASSWORD=""
85
+MYSQLHOST="localhost"
86
+
87
+# settings by command line options
88
+if optval.has_key('-u'):
89
+    MYSQLUSER = optval['-u']
90
+if optval.has_key('-p'):
91
+    MYSQLPASSWORD = optval['-p']
92
+if optval.has_key('-D'):
93
+    MYSQLDB = optval['-D']
94
+if optval.has_key('-H'):
95
+    MYSQLHOST = optval['-H']
96
+
97
+if optval.has_key('-q'):
98
+    quota = optval['-q']
99
+else:
100
+    quota = 0
101
+
102
+if optval.has_key('-n'):
103
+    seed_len = optval['-n']
104
+else:
105
+    seed_len = 8
106
+
107
+# check arguments, only the user list file must be present
108
+if len(args) !=1:
109
+    print 'Need just one argument'
110
+    usage()
111
+    sys.exit(1)
112
+
113
+# MySQL connection (skipped in test run)
114
+if optval.has_key('-t'):
115
+    print "Test Run"
116
+else:
117
+    try:
118
+        connection = MySQLdb.connect(host=MYSQLHOST, user=MYSQLUSER, 
119
+                                     db=MYSQLDB, passwd=MYSQLPASSWORD)
120
+    except MySQLdb.MySQLError, e:
121
+        print "Database connection error"
122
+        print e
123
+        sys.exit(1)
124
+ 
125
+    cursor = connection.cursor()
126
+
127
+#
128
+# Main body
129
+#
130
+NOW = datetime.now().strftime("%Y-%m-%d %H:%M:%S")
131
+
132
+# read and convert CSV data
133
+lista = csv.DictReader(open(args[0]))
134
+
135
+def gen_seed(seed_len, chars):
136
+    return '$1$'+''.join([random.choice(chars) for _ in xrange(seed_len)])+'$'
137
+
138
+def insert_record(cursor,table,record):
139
+    columns = record.keys()
140
+    query = "INSERT INTO " + table + "(" + ','.join(columns) + ") VALUES (" + ','.join(len(columns)*['%s']) + ")"
141
+    try:
142
+        cursor.execute(query, record.values())
143
+        return 0
144
+    except MySQLdb.MySQLError, e:
145
+        print "Database insertion error"
146
+        print e
147
+        print "Record was:"
148
+        print record.values()
149
+        print "Query was:"
150
+        print query
151
+
152
+# defining default values for tables (mailbox, alias and domain)
153
+mailbox = {
154
+    'created': NOW, 
155
+    'modified': NOW,
156
+    'active': 1,
157
+    'quota': quota
158
+    }
159
+aliases = {
160
+    'created':  NOW,
161
+    'modified': NOW,
162
+    'active':   1
163
+    }
164
+domain = {
165
+    'description': "",
166
+    'aliases': 0,
167
+    'mailboxes': 0,
168
+    'quota': 0,
169
+    'transport': 'virtual',
170
+    'backupmx': 0,
171
+    'created': NOW,
172
+    'modified': NOW,
173
+    'active': 1
174
+}
175
+
176
+# list of default alias
177
+def_alias = ['abuse','hostmaster','postmaster','webmaster'] 
178
+
179
+domain_list = {}
180
+chars = string.letters + string.digits
181
+
182
+# loop over the CSV 
183
+for row in lista:
184
+    # create domain if it does not exists
185
+    if domain_list.has_key(row["domain"]):
186
+        if optval.has_key('-d'):
187
+            print "Domain " + row["domain"] + "already exixts"
188
+    else:
189
+        domain_list[row["domain"]] = 1
190
+        domain['domain'] = row["domain"]
191
+        if optval.has_key('-t'):
192
+            print "Inserting domain"
193
+            print domain
194
+        else:
195
+            insert_record(cursor,'domain',domain)
196
+            if optval.has_key('-A'):
197
+                for i in def_alias:
198
+                    aliases['address']= i+'@'+row["domain"]
199
+                    aliases['goto']= aliases['address']
200
+                    aliases['domain'] = row["domain"]
201
+                    if optval.has_key('-t'):
202
+                        print "Inserting alias"
203
+                        print aliases
204
+                    else:
205
+                        insert_record(cursor,'alias',aliases)
206
+
207
+    # build query data for mailbox table
208
+    mailbox['username']=row["user"]+'@'+row["domain"]
209
+    encpass=crypt(row["password"], gen_seed(seed_len,chars))
210
+    mailbox['password'] = encpass
211
+    mailbox['name'] = row["name"]
212
+    mailbox['maildir'] = row["domain"]+'/'+row["user"]+'/'
213
+    mailbox['local_part'] =row["user"]
214
+    mailbox['domain'] = row["domain"]
215
+
216
+    # build query data for alias table
217
+    aliases['address']= mailbox['username']
218
+    aliases['goto']= mailbox['username']
219
+    aliases['domain'] = row["domain"]
220
+
221
+    # inserting data for mailbox (and relate alias)
222
+    if optval.has_key('-t'):
223
+        print "Inserting mailbox"
224
+        print mailbox
225
+        print aliases
226
+    else:
227
+        insert_record(cursor,'mailbox',mailbox)
228
+        insert_record(cursor,'alias',aliases)
229
+
230
+
231
+sys.exit(0)

+ 124
- 0
postfixadmin/postfixadmin-3.0/ADDITIONS/mailbox_remover.pl View File

@@ -0,0 +1,124 @@
1
+#!/usr/bin/perl
2
+#
3
+# by Petr Znojemsky (c) 2004
4
+# Mailbox remover 0.1a 23/10/2004 - the very first version for MySQL
5
+# removes maildirs from disk when they are not found in a database
6
+#
7
+# Added subdir support and pause --- Alan Batie 2007
8
+# Lists directories to be deleted then pauses for 5 seconds for chance to abort
9
+# $Id: mailbox_remover.pl 211 2007-11-11 23:36:46Z christian_boltz $
10
+#
11
+# All your maildirs or other directories could be accidentally removed.
12
+# Use it at own risk. No warranties!
13
+
14
+use strict;
15
+use DBI;
16
+use File::Path;
17
+
18
+##########
19
+# Set these variables according to your configuration
20
+
21
+# when mailboxes are removed, save their tarballs here
22
+my $archdir="/var/archive/mailboxes";
23
+
24
+# expected to support z option, tweak invocation if you want different
25
+my $archcmd="/usr/bin/tar";
26
+
27
+# trailing slash not needed
28
+my $maildir_path="/var/mail";
29
+# find out if we need to check subdirs for mailboxes or just maildir_path
30
+# $CONF['domain_path'] = 'YES';
31
+my $pfadmin_config="/usr/local/www/postfixadmin/config.inc.php";
32
+
33
+# database information
34
+my $host="localhost";
35
+my $port="3306";
36
+my $userid="dbuser";
37
+my $passwd="dbpw";
38
+my $db="dbname";
39
+############
40
+
41
+my $connectionInfo="DBI:mysql:database=$db;$host:$port";
42
+# make connection to database
43
+my $dbh = DBI->connect($connectionInfo,$userid,$passwd);
44
+# prepare and execute query
45
+my $query = "SELECT maildir FROM mailbox";
46
+my $sth = $dbh->prepare($query);
47
+$sth->execute();
48
+
49
+# assign fields to variables
50
+my ($db_maildir, %db_maildirs);
51
+$sth->bind_columns(\$db_maildir);
52
+
53
+# load up directory list
54
+while($sth->fetch()) {
55
+    $db_maildirs{$db_maildir} = 1;
56
+}
57
+
58
+$sth->finish();
59
+# disconnect from database
60
+$dbh->disconnect;
61
+
62
+# 
63
+# find out if we need to check subdirs for mailboxes or just maildir_path
64
+# $CONF['domain_path'] = 'YES';
65
+#
66
+my $use_subdirs = 0;
67
+open(CONFIG, "<$pfadmin_config") || die "Can't open '$pfadmin_config': $!\n";
68
+while(<CONFIG>) {
69
+    if (/\$CONF\['domain_path'\] *= *'([^']*)'/) {
70
+	$use_subdirs = ($1 =~ /yes/i);
71
+    }
72
+}
73
+close(CONFIG);
74
+
75
+# store maildir list to %directories
76
+# key is path, value is username to use in archive file
77
+my %directories;
78
+opendir(DIR, $maildir_path) || die "Cannot open dir $maildir_path: $!\n";
79
+foreach my $name (readdir(DIR)) {
80
+    next if ($name eq '.' || $name eq '..' || ! -d "$maildir_path/$name");
81
+
82
+    if ($use_subdirs) {
83
+	opendir(SUBDIR, "$maildir_path/$name") || die "Cannot open dir $maildir_path/$name: $!\n";
84
+	foreach my $subname (readdir(SUBDIR)) {
85
+	    next if ($subname eq '.' || $subname eq '..' || ! -d "$maildir_path/$name/$subname");
86
+	    # db entry has trailing slash...
87
+	    if (!defined($db_maildirs{"$name/$subname/"})) {
88
+	        print "marking $maildir_path/$name/$subname for deletion.\n";
89
+		$directories{"$name/$subname"} = "$name-$subname";
90
+	    }
91
+	}
92
+	closedir(SUBDIR);
93
+    } else {
94
+	# db entry has trailing slash...
95
+	if (!defined($db_maildirs{"$name/"})) {
96
+	    print "marking $maildir_path/$name for deletion.\n";
97
+	    $directories{"$name"} = $name;
98
+	}
99
+    }
100
+}
101
+closedir(DIR);
102
+
103
+print "Ctrl-C in 5 seconds to abort before removal starts...\n";
104
+sleep 5;
105
+
106
+my ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime(time);
107
+# yyyymmddhhmm
108
+my $tstamp = sprintf("%04d%02d%02d%02d%02d", $year+1900, $mon+1, $mday, $hour, $min);
109
+
110
+# compare two arrays and erase maildirs not found in database
111
+chdir $maildir_path || die "Can't change to maildir '$maildir_path': $!\n";;
112
+my @args;
113
+foreach my $maildir (keys(%directories)) {
114
+    my $archive = "$archdir/$directories{$maildir}-$tstamp.tgz";
115
+    # quick permissions check
116
+    open(TOUCH, ">$archive") || die "Can't create archive file $archive: $!\n";
117
+    close(TOUCH);
118
+    print "Archiving $maildir\n";
119
+    @args = ($archcmd, "cvzf", $archive, $maildir);
120
+	system(@args) == 0 or die "Creating archive for $maildir failed: $?"
121
+
122
+    rmtree($maildir);
123
+    print localtime() . " $maildir has been deleted.\n";
124
+}

+ 167
- 0
postfixadmin/postfixadmin-3.0/ADDITIONS/mkeveryone.pl View File

@@ -0,0 +1,167 @@
1
+#!/usr/bin/perl
2
+#
3
+# Generate an 'everybody' alias for a domain.
4
+#
5
+# Create the file /etc/mkeveryone.conf
6
+# chmod 640 /etc/mkeveryone.conf
7
+# Example of mkeveryone.conf
8
+#
9
+# userid=postfix
10
+# passwd=postfix
11
+# db=postfix
12
+# host=localhost
13
+# port=3306
14
+# domain=domain.tld
15
+# target=everybody@domain.tld
16
+# ignore=vacation@domain.tld
17
+# ignore=spam@domain.tld
18
+# ignore=newsletter@domain.tld
19
+# ignore=root@domain.tld
20
+#
21
+# Save this file in, for example, /usr/local/sbin/mkeveryone.pl
22
+# chmod 750 /usr/local/sbin/mkeveryone.pl
23
+#
24
+# Run the script!
25
+#
26
+use DBI;
27
+use Time::Local;
28
+use POSIX qw(EAGAIN);
29
+use Fcntl;
30
+use IO;
31
+use IO::File;
32
+
33
+my $timeNow=time();
34
+
35
+my $DATFILE     = "/etc/mkeveryone.conf";
36
+my $FILEHANDLE  = "";
37
+
38
+# database information
39
+my $db="postfix";
40
+my $host="localhost";
41
+my $port="3306";
42
+my $userid="postfix";
43
+my $passwd="postfix";
44
+my $domain="domain.tld";
45
+my $target="everyone@$domain";
46
+my @ignore;
47
+my @dest;
48
+
49
+open (FILEHANDLE, $DATFILE);
50
+
51
+while ( $LINE = <FILEHANDLE> ) {
52
+
53
+       if ( length $LINE > 0 ) {
54
+       chomp $LINE;
55
+
56
+           $RETURNCODE = 0;
57
+
58
+           SWITCH: {
59
+
60
+               $LINE =~ /^ignore/i and do {
61
+                   $LINE =~ s/^ignore// && $LINE =~ s/=// && $LINE =~ s/^ //g;
62
+                   @ignore = (@ignore,$LINE);
63
+                };
64
+
65
+               $LINE =~ /^userid/i and do {
66
+                   # Userid found.";
67
+                   $LINE =~ s/^userid// && $LINE =~ s/=// && $LINE =~ s/^ //g;
68
+                   $userid = $LINE;
69
+               };
70
+
71
+               $LINE =~ /^passwd/i and do {
72
+                   # Passwd found.";
73
+                   $LINE =~ s/^passwd// && $LINE =~ s/=// && $LINE =~ s/^ //g;
74
+                   $passwd = $LINE;
75
+               };
76
+
77
+               $LINE =~ /^db/i and do {
78
+                   # Database found.";
79
+                   $LINE =~ s/^db// && $LINE =~ s/=// && $LINE =~ s/^ //g;
80
+                   $db = $LINE;
81
+               };
82
+
83
+               $LINE =~ /^host/i and do {
84
+                   # Database host found.";
85
+                   $LINE =~ s/^host// && $LINE =~ s/=// && $LINE =~ s/^ //g;
86
+                   $host = $LINE;
87
+               };
88
+
89
+               $LINE =~ /^port/i and do {
90
+                   # Database host found.";
91
+                   $LINE =~ s/^port// && $LINE =~ s/=// && $LINE =~ s/^ //g;
92
+                   $port = $LINE;
93
+               };
94
+
95
+               $LINE =~ /^target/i and do {
96
+                   # Database host found.";
97
+                   $LINE =~ s/^target// && $LINE =~ s/=// && $LINE =~ s/^ //g;
98
+                   $target = $LINE;
99
+               };
100
+
101
+               $LINE =~ /^domain/i and do {
102
+                   # Database host found.";
103
+                   $LINE =~ s/^domain// && $LINE =~ s/=// && $LINE =~ s/^ //g;
104
+                   $domain = $LINE;
105
+               };
106
+          }
107
+       }
108
+}
109
+
110
+print "Connecting to database $db on $host:$port...\n\r";
111
+
112
+print "Target email address is $target...\n\r";
113
+
114
+my $connectionInfo="DBI:mysql:database=$db;$host:$port";
115
+
116
+# make connection to database
117
+$dbh = DBI->connect($connectionInfo,$userid,$passwd);
118
+
119
+# Delete the old message...prepare and execute query
120
+$query = "SELECT username FROM mailbox WHERE domain='$domain';";
121
+$sth = $dbh->prepare($query);
122
+$sth->execute();
123
+
124
+# assign fields to variables
125
+$sth->bind_columns(\$username);
126
+
127
+my $ign="false";
128
+while($sth->fetch()) {
129
+  $ign = "false";
130
+
131
+  foreach $ignored ( @ignore ) {
132
+     if ( $username eq $ignored ){
133
+          $ign = "true";
134
+          }
135
+  }
136
+
137
+  if ( $ign eq "false" ) {
138
+       @dest = (@dest,$username);
139
+  }
140
+}
141
+
142
+# Delete the old aliases...prepare and execute query
143
+$query = "DELETE FROM alias WHERE address='$target';";
144
+$sth = $dbh->prepare($query);
145
+$sth->execute();
146
+
147
+print "Record deleted from the database.\r\n";
148
+
149
+$sth->finish();
150
+
151
+$goto = join(",",@dest);
152
+print "$goto\n\r\n\r";
153
+
154
+
155
+# Insert the new message...prepare and execute query
156
+$query = "INSERT INTO alias (address,goto,domain,created,modified) VALUES ('$target','$goto','$domain',now(),now());";
157
+
158
+$sth = $dbh->prepare($query);
159
+$sth->execute();
160
+
161
+print "Record added to the database.\r\n";
162
+
163
+$sth->finish();
164
+
165
+# disconnect from databse
166
+$dbh->disconnect;
167
+

+ 111
- 0
postfixadmin/postfixadmin-3.0/ADDITIONS/pfa_maildir_cleanup.pl View File

@@ -0,0 +1,111 @@
1
+#!/usr/bin/perl
2
+#
3
+##
4
+## pfa_maildir_cleanup.pl
5
+##
6
+## (c) 2004 by Stephen Fulton (sfulton@esoteric.ca)
7
+##
8
+## based on a script by Petr Znojemsky (thanks!) 
9
+##
10
+## Simple script to remove maildirs/domains not listed in a MySQL database.
11
+## Set up for use with those using PostfixAdmin, but can be adapted.
12
+##
13
+## Edit the variables between the ##EDIT## to match your setup.
14
+##
15
+## USE AT YOUR OWN RISK. I ASSUME NO RESPONSIBILITY.
16
+##
17
+
18
+use DBI;
19
+use File::Path;
20
+
21
+##EDIT## 
22
+
23
+$root_path = "/home/mail";
24
+$logfile = "/var/log/removed_maildirs.log";
25
+
26
+$db_host = "localhost";
27
+$db_database = "database";
28
+$db_user = "username";
29
+$db_password = 'password';
30
+
31
+##END EDIT##
32
+
33
+
34
+$connectionInfo = "DBI:mysql:database=$db_database;$db_host:3306";
35
+
36
+## Read a list of domain directories in the root path /remote/mail1
37
+
38
+opendir(DIRHANDLE, $root_path) || die "Cannot access directory $maildir_path: $!";
39
+
40
+my @directories = ();
41
+
42
+foreach $directory (sort readdir(DIRHANDLE)) {
43
+   push (@directories, $directory);
44
+}
45
+
46
+closedir(DIRHANDLE);
47
+
48
+## Strip the "." and ".." from the directories array
49
+
50
+($dot, $doubledot, @directories) = @directories;
51
+
52
+## For each of the domain directories..
53
+
54
+foreach $domain_dir (@directories) {
55
+   $complete_domain_path = "$root_path/$domain_dir";
56
+
57
+   ## Get a list of user directories within each domain directory...
58
+
59
+   opendir(DOMAINHANDLE, $complete_domain_path) || die "Cannot access directory $complete_domain_path: $!";
60
+
61
+   my @user_directories = ();
62
+
63
+   foreach $dir (sort readdir(DOMAINHANDLE)) {
64
+      push(@user_directories, $dir);
65
+   }
66
+   close(DOMAINHANDLE);
67
+
68
+   ## Now remove any "." or ".." directory entries and construct a domain/maildir variable
69
+   ## valid for one iteration of loop.
70
+
71
+   foreach $user_directory (@user_directories) {
72
+      if( not($user_directory eq '..') && not($user_directory eq '.') ) {
73
+         $short_user_dir = "$domain_dir/$user_directory/";
74
+
75
+         ## Here is where the $short_user_dir is compared against the DB entry.
76
+
77
+         $dbh = DBI->connect($connectionInfo,$db_user,$db_password);
78
+         $user_query = "SELECT maildir FROM mailbox WHERE maildir = '$short_user_dir'";
79
+         $sth = $dbh->prepare($user_query);
80
+         $rows = $sth->execute();
81
+
82
+         ## If there are no rows that match, then directory is orphaned and can
83
+         ## be deleted.
84
+
85
+         if($rows == 0) {
86
+            $maildir_path = "$root_path/$short_user_dir";
87
+            open(INFO, ">>$logfile") || die "Cannot write to the logfile: $logfile.";
88
+            rmtree($maildir_path);
89
+            print INFO localtime()." Maildir ".$maildir_path." has been deleted.\n";
90
+            (INFO);
91
+         }
92
+         $sth->finish;
93
+         $dbh->disconnect;
94
+      }
95
+   }
96
+
97
+   $dbh2 = DBI->connect($connectionInfo,$db_user,$db_password);
98
+   $domain_query = "SELECT domain FROM domain WHERE domain = '$domain_dir'";
99
+   $sth2 = $dbh2->prepare($domain_query);
100
+   $domain_rows = $sth2->execute();
101
+
102
+   if($domain_rows == 0) {
103
+      open(INFO, ">>$logfile") || die "Cannot write to the logfile: $logfile.";
104
+      rmtree($complete_domain_path);
105
+      print INFO localtime()." Domain directory ".$complete_domain_path." has been deleted.\n";
106
+      close(INFO);
107
+   }
108
+
109
+$sth2->finish;
110
+$dbh2->disconnect;
111
+}

+ 62
- 0
postfixadmin/postfixadmin-3.0/ADDITIONS/postfixadmin-domain-postdeletion.sh View File

@@ -0,0 +1,62 @@
1
+#!/bin/sh
2
+
3
+# Example script for removing a Maildir domain top-level folder
4
+# from a Courier-IMAP virtual mail hierarchy.
5
+
6
+# The script only looks at argument 1, assuming that it 
7
+# indicates the relative name of a domain, such as
8
+# "somedomain.com". If $basedir/somedomain.com exists, it will
9
+# be removed.
10
+
11
+# The script will not actually delete the directory. I moves it
12
+# to a special directory which may once in a while be cleaned up
13
+# by the system administrator.
14
+
15
+# This script should be run as the user which owns the maildirs. If 
16
+# the script is actually run by the apache user (e.g. through PHP),
17
+# then you could use "sudo" to grant apache the rights to run
18
+# this script as the relevant user.
19
+# Assume this script has been saved as
20
+# /usr/local/bin/postfixadmin-domain-postdeletion.sh and has been
21
+# made executable. Now, an example /etc/sudoers line:
22
+# apache ALL=(courier) NOPASSWD: /usr/local/bin/postfixadmin-domain-postdeletion.sh
23
+# The line states that the apache user may run the script as the
24
+# user "courier" without providing a password.
25
+
26
+
27
+# Change this to where you keep your virtual mail users' maildirs.
28
+basedir=/var/spool/maildirs
29
+
30
+# Change this to where you would like deleted maildirs to reside.
31
+trashbase=/var/spool/deleted-maildirs
32
+
33
+if [ `echo $1 | fgrep '..'` ]; then
34
+    echo "First argument contained a double-dot sequence; bailing out."
35
+    exit 1
36
+fi
37
+
38
+if [ ! -e "$trashbase" ]; then
39
+    echo "trashbase '$trashbase' does not exist; bailing out."
40
+    exit 1
41
+fi
42
+
43
+trashdir="${trashbase}/`date +%F_%T`_$1"
44
+domaindir="${basedir}/$1"
45
+
46
+if [ ! -e "$domaindir" ]; then
47
+    echo "Directory '$domaindir' does not exits; nothing to do."
48
+    exit 0;
49
+fi
50
+if [ ! -d "$domaindir" ]; then
51
+    echo "'$domaindir' is not a directory; bailing out."
52
+    exit 1
53
+fi
54
+if [ -e "$trashdir" ]; then
55
+    echo "Directory '$trashdir' already exits; bailing out."
56
+    exit 1;
57
+fi
58
+
59
+mv $domaindir $trashdir
60
+
61
+exit $?
62
+

+ 61
- 0
postfixadmin/postfixadmin-3.0/ADDITIONS/postfixadmin-mailbox-postcreation.sh View File

@@ -0,0 +1,61 @@
1
+#!/bin/sh
2
+
3
+# Example script for adding a Maildir to a Courier-IMAP virtual mail
4
+# hierarchy.
5
+
6
+# The script only looks at argument 3, assuming that it 
7
+# indicates the relative name of a maildir, such as
8
+# "somedomain.com/peter/".
9
+
10
+# This script should be run as the user which owns the maildirs. If 
11
+# the script is actually run by the apache user (e.g. through PHP),
12
+# then you could use "sudo" to grant apache the rights to run
13
+# this script as the relevant user.
14
+# Assume this script has been saved as
15
+# /usr/local/bin/postfixadmin-mailbox-postcreation.sh and has been
16
+# made executable. Now, an example /etc/sudoers line:
17
+# apache ALL=(courier) NOPASSWD: /usr/local/bin/postfixadmin-mailbox-postcreation.sh
18
+# The line states that the apache user may run the script as the
19
+# user "courier" without providing a password.
20
+
21
+
22
+# Change this to where you keep your virtual mail users' maildirs.
23
+basedir=/var/spool/maildirs
24
+
25
+if [ ! -e "$basedir" ]; then
26
+    echo "$0: basedir '$basedir' does not exist; bailing out."
27
+    exit 1
28
+fi
29
+
30
+if [ `echo $3 | fgrep '..'` ]; then
31
+    echo "$0: An argument contained a double-dot sequence; bailing out."
32
+    exit 1
33
+fi
34
+
35
+maildir="${basedir}/$3"
36
+parent=`dirname "$maildir"`
37
+if [ ! -d "$parent" ]; then
38
+    if [ -e "$parent" ]; then
39
+        echo "$0: strange - directory '$parent' exists, but is not a directory; bailing out."
40
+        exit 1
41
+    else
42
+        mkdir -p "${parent}"
43
+        if [ $? -ne 0 ]; then
44
+            echo "$0: mkdir -p '$parent' returned non-zero; bailing out."
45
+            exit 1
46
+        fi
47
+    fi
48
+fi
49
+
50
+if [ -e "$maildir" ]; then
51
+    echo "$0: Directory '$maildir' already exists! bailing out"
52
+    exit 1
53
+fi
54
+
55
+maildirmake "$maildir"
56
+if [ ! -d "$maildir" ]; then
57
+    echo "$0: maildirmake didn't produce a directory; bailing out."
58
+    exit 1
59
+fi
60
+
61
+exit 0

+ 77
- 0
postfixadmin/postfixadmin-3.0/ADDITIONS/postfixadmin-mailbox-postdeletion.sh View File

@@ -0,0 +1,77 @@
1
+#!/bin/sh
2
+
3
+# Example script for removing a Maildir from a Courier-IMAP virtual mail
4
+# hierarchy.
5
+
6
+# The script looks at arguments 1 and 2, assuming that they 
7
+# indicate username and domain, respectively.
8
+
9
+# The script will not actually delete the maildir. I moves it
10
+# to a special directory which may once in a while be cleaned up
11
+# by the system administrator.
12
+
13
+# This script should be run as the user which owns the maildirs. If 
14
+# the script is actually run by the apache user (e.g. through PHP),
15
+# then you could use "sudo" to grant apache the rights to run
16
+# this script as the relevant user.
17
+# Assume this script has been saved as
18
+# /usr/local/bin/postfixadmin-mailbox-postdeletion.sh and has been
19
+# made executable. Now, an example /etc/sudoers line:
20
+# apache ALL=(courier) NOPASSWD: /usr/local/bin/postfixadmin-mailbox-postdeletion.sh
21
+# The line states that the apache user may run the script as the
22
+# user "courier" without providing a password.
23
+
24
+
25
+# Change this to where you keep your virtual mail users' maildirs.
26
+basedir=/var/spool/maildirs
27
+
28
+# Change this to where you would like deleted maildirs to reside.
29
+trashbase=/var/spool/deleted-maildirs
30
+
31
+
32
+if [ ! -e "$trashbase" ]; then
33
+    echo "trashbase '$trashbase' does not exist; bailing out."
34
+    exit 1
35
+fi
36
+
37
+if [ `echo $1 | fgrep '..'` ]; then
38
+    echo "First argument contained a double-dot sequence; bailing out."
39
+    exit 1
40
+fi
41
+if [ `echo $2 | fgrep '..'` ]; then
42
+    echo "First argument contained a double-dot sequence; bailing out."
43
+    exit 1
44
+fi
45
+
46
+subdir=`echo "$1" | sed 's/@.*//'`
47
+
48
+maildir="${basedir}/$2/${subdir}"
49
+trashdir="${trashbase}/$2/`date +%F_%T`_${subdir}"
50
+
51
+parent=`dirname "$trashdir"`
52
+if [ ! -d "$parent" ]; then
53
+    if [ -e "$parent" ]; then
54
+        echo "Strainge - directory '$parent' exists, but is not a directory."
55
+        echo "Bailing out."
56
+        exit 1
57
+    else
58
+        mkdir -p "$parent"
59
+        if [ $? -ne 0 ]; then
60
+            echo "mkdir -p '$parent' returned non-zero; bailing out."
61
+            exit 1
62
+        fi
63
+    fi
64
+fi
65
+
66
+if [ ! -e "$maildir" ]; then
67
+    echo "maildir '$maildir' does not exist; nothing to do."
68
+    exit 1
69
+fi
70
+if [ -e "$trashdir" ]; then
71
+    echo "trashdir '$trashdir' already exists; bailing out."
72
+    exit 1
73
+fi
74
+
75
+mv $maildir $trashdir
76
+
77
+exit $?

+ 151
- 0
postfixadmin/postfixadmin-3.0/ADDITIONS/quota_usage.pl View File

@@ -0,0 +1,151 @@
1
+#!/usr/bin/perl
2
+# vim:ts=4:sw=4:et
3
+# Virtual quota_usage 0.3
4
+# Contributed to Postfixadmin by Jose Nilton <jniltinho@gmail.com> 
5
+#
6
+# See also : http://www.russelldare.net/media/perl/dirsizeSource.pdf
7
+# License: GPL v2.
8
+
9
+# Usage:
10
+# perl quota_usage.pl --list 
11
+# perl quota_usage.pl --list --addmysql 
12
+#                                      for add mysql database postfix 
13
+#
14
+# Requirements - the following perl modules are required:
15
+# DBD::Pg or DBD::mysql; perl perl-DBD-mysql perl-DBD (may be named differently depending on your platform).
16
+#           and the 'du' binary in $ENV{'PATH'} (see below).
17
+#
18
+# You will need to modify the postfix DATABASE to add a quota_usage column. 
19
+# Mysql:
20
+# 	ALTER TABLE mailbox ADD quota_usage INT(11) NOT NULL DEFAULT '0' AFTER modified, 
21
+# 	ADD quota_usage_date DATE NOT NULL DEFAULT '0000-00-00' AFTER quota_usage;
22
+# PostgreSQL:
23
+# 	ALTER TABLE mailbox ADD COLUMN quota_usage INTEGER NOT NULL DEFAULT 0;
24
+# 	ALTER TABLE mailbox ADD COLUMN quota_usage_date DATE NOT NULL DEFAULT current_date;
25
+#
26
+
27
+use strict;
28
+use warnings;
29
+use File::Path;
30
+use DBI;
31
+use Getopt::Long;
32
+
33
+##EDIT## 
34
+my $db_host 	= 'localhost';
35
+my $db_database = 'postfix';
36
+my $db_user 	= 'postfix';
37
+my $db_password = '123456';
38
+my $root_path 	= '/home/vmail';
39
+# Pg or mysql
40
+my $db_type     = 'mysql'; 
41
+##END EDIT##
42
+
43
+(help()) if (!$ARGV[0]);
44
+
45
+$ENV{'PATH'} = "/sbin:/bin:/usr/sbin:/usr/bin";
46
+my($domain_dir, $full_domain_dir, $user_dir, $usage, $email, $sql, $dbh);
47
+
48
+my $list = 0;
49
+my $insert_db = 0;
50
+my $total_mailbox = 0;
51
+my $total_domain = 0;
52
+GetOptions ('l|list' => \$list, 'i|addmysql' => \$insert_db, 'help|h|man' => \&help) or (help());
53
+
54
+
55
+(list_quota_usage()) if ($list == 1 || $insert_db == 1 );
56
+
57
+
58
+
59
+sub list_quota_usage {
60
+    opendir(DOMAINDIR, $root_path) or die ("Unable to access directory '$root_path' ($!)");
61
+
62
+    if($insert_db == 1){
63
+        $dbh = DBI->connect("DBI:$db_type:database=$db_database;host=$db_host", $db_user, $db_password) or die ("cannot connect the database");
64
+        execSql("UPDATE mailbox set quota_usage = 0");
65
+    }
66
+
67
+    foreach $domain_dir (sort readdir DOMAINDIR) {
68
+        next if $domain_dir =~ /^\./;                    # skip dotted dirs
69
+        $full_domain_dir = "$root_path/$domain_dir"; #print "$full_domain_dir\n";
70
+        $total_domain++;            
71
+
72
+        opendir(USERDIR, $full_domain_dir) or die ("Unable to access directory '$full_domain_dir' ($!)");
73
+        foreach $user_dir (sort readdir USERDIR) {
74
+            next if $user_dir =~ /^\./; # skip dotted dirs
75
+            $email = "$user_dir\@$domain_dir";
76
+            $total_mailbox++;
77
+
78
+            my $i = `du -0 --summarize $full_domain_dir/$user_dir`;
79
+            ($usage) = split(" ", $i);
80
+
81
+            if ($usage < 100) {
82
+                $usage = 0;
83
+            } elsif ($usage < 1000) {
84
+                $usage = 1;
85
+            } else {
86
+                $usage = $usage + 500;
87
+                $usage = int $usage / 1000;
88
+            }
89
+            if($insert_db == 1){execSql("UPDATE mailbox set quota_usage = $usage, quota_usage_date = CAST(NOW() AS DATE) WHERE username = '$email'");}
90
+            print_list() if ($list == 1);
91
+
92
+        }
93
+    }
94
+    close(DOMAINDIR);
95
+    close(USERDIR);
96
+
97
+    (print_total()) if ($list == 1);
98
+
99
+}
100
+
101
+
102
+
103
+
104
+
105
+sub execSql {
106
+    my $sql = shift;
107
+    my $ex;
108
+    $ex = $dbh->do($sql) or die ("error when running $sql");
109
+}
110
+
111
+
112
+
113
+sub print_total{
114
+    print "---------------------------------------------------------\n";
115
+    print "TOTAL DOMAIN\t\t\t\tTOTAL MAILBOX\n";
116
+    print "---------------------------------------------------------\n";
117
+    print "$total_domain\t\t\t\t\t\t$total_mailbox\n";
118
+}
119
+
120
+
121
+
122
+sub print_list {
123
+format STDOUT_TOP =
124
+Report of Quota Used
125
+---------------------------------------------------------
126
+EMAIL                                         QUOTA USED
127
+---------------------------------------------------------
128
+.
129
+
130
+
131
+format = 
132
+@<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<         @<<<<<<<<<<
133
+$email,                                           "$usage MB"                         
134
+.
135
+
136
+    write;
137
+}
138
+
139
+
140
+
141
+
142
+
143
+sub help {
144
+    print "$0 [options...]\n";
145
+    print "-l|--list                     List quota used\n";
146
+    print "-i|--addmysql                 For insert quota used in database mysql\n";
147
+
148
+}
149
+
150
+
151
+

+ 38
- 0
postfixadmin/postfixadmin-3.0/ADDITIONS/squirrelmail-plugin/INSTALL View File

@@ -0,0 +1,38 @@
1
+Installing the postfixadmin Plugin
2
+======================================
3
+
4
+Requirements:
5
+=============
6
+
7
+ - PHP 5.[234].* with php5-xmlrpc installed (if available; it should be available by default anyway)
8
+ - http access to a local/remote postfixadmin interface 
9
+ - Zend Framework (1.12.x) - needs adding to the include path within common.php, 
10
+   or installing in a system include path directory (e.g. /usr/share/php)
11
+   (e.g. from within the directory containing this file ...
12
+	wget https://packages.zendframework.com/releases/ZendFramework-1.12.3/ZendFramework-1.12.3-minimal.tar.gz 
13
+	tar -zxf ZendFramework-1.12.3-minimal.tar.gz
14
+	mv ZendFramework-1.12.3-minimal/library/Zend .    )
15
+   NOTE: This plugin is _not compatible_ with Zend Framework version 2.x.
16
+
17
+Installation :
18
+==============
19
+
20
+- Copy this code into the Squirrelmail plugins directory - your life will be easiest if it's in a directory called 'postfixadmin'
21
+- Install Zend Framework (see above under Requirements for example)
22
+- Edit config.php and specify the remote URL for the Postfixadmin XmlRpc service. 
23
+- Edit common.php and (if you need to) change the include path(s) so they are correct.
24
+- Edit the remote Postfixadmin's XmlRpc service config file and ensure 'xmlrpc_enabled' is set to boolean true.
25
+- Enable the plugin through 'squirrelmail-configure' or 'config/conf.pl'.  
26
+   Choose option 8 and move the plugin from the "Available Plugins"
27
+   category to the "Installed Plugins" category.  Save and exit.
28
+
29
+Security :
30
+==========
31
+
32
+- The XmlRpc client needs to get the user's mailbox password before it will be able to connect to the
33
+  XmlRpc server (postfixadmin). The plugin prompts the user for their mailbox password, and caches it in their session
34
+  ($_SESSION['password']). This password is then sent once on every page load to the remote XmlRpc server.
35
+
36
+- You should consider doing any of the following :
37
+ - Using https if the server and client are on seperate servers. This will probably require a signed certificate etc, and may require changes to the Zend_XmlRpc_Client's HttpClient.
38
+ - Using something like stunnel to encrypt traffic between server(s).

+ 40
- 0
postfixadmin/postfixadmin-3.0/ADDITIONS/squirrelmail-plugin/LICENSE.txt View File

@@ -0,0 +1,40 @@
1
+
2
+2007/03/29 :
3
+    Before I (David Goodwin) customised this plugin, it contained the following within all
4
+    files as a header. 
5
+
6
+    /****************************************************************************************
7
+
8
+        Author ......... Florian Kimmerl
9
+        Contact ........ info@spacekoeln.de
10
+        Home Site ...... http://www.spacekoeln.de/
11
+        Program ........ postfixadmin
12
+        Purpose ........ Allows you to change your postfixadmin settings within squirrelmail
13
+
14
+        *************************************************************************************
15
+
16
+        The Original Code is Postfix Admin.
17
+        The Initial Developer of the Original Code is Mischa Peters .
18
+        Portions created by Mischa Peters are Copyright (c) 2002, 2003, 2004.
19
+        All Rights Reserved.
20
+        Contributor(s):
21
+        This project includes work by Mischa Peters and others that is:
22
+        Copyright (c) 2002,2003,2004 Mischa Peters
23
+        All rights reserved.
24
+
25
+    ****************************************************************************************/
26
+
27
+    
28
+    Contacting the author provided no success, so I took over maintainership.
29
+
30
+    Please note:
31
+
32
+    1) Changes made by myself (David Goodwin) will be licensed under the GPL
33
+    2) PostfixAdmin has itself been relicensed under the GPL; however this took place _after_
34
+       this plugin was written.
35
+    3) Squirrelmail itself is released under http://squirrelmail.org/wiki/SquirrelMailGPL (GPL)
36
+
37
+
38
+The GNU public license can be found online at :
39
+
40
+    http://www.gnu.org/licenses/gpl.txt

+ 70
- 0
postfixadmin/postfixadmin-3.0/ADDITIONS/squirrelmail-plugin/README View File

@@ -0,0 +1,70 @@
1
+Squirrelmail Plugin Postfixadmin
2
+********************************
3
+
4
+The Postfixadmin SquirrelMail plugin let users change their virtual alias,
5
+vacation status/message and password if you are using the great postfixadmin
6
+tool from http://high5.net/postfixadmin
7
+
8
+Version 0.4.3   2007/08/14
9
+
10
+Postfixadmin - Postfixadmin+MySQL/PgSQL plugin for Squirrelmail
11
+
12
+
13
+Author: Florian Kimmerl <info@spacekoeln.de>
14
+Author: Sam Brookes <sam at pale purple.co.uk>
15
+    - Initial conversion to MDB2
16
+    - Fix SQL Injections etc
17
+Author: David Goodwin <david at pale purple.co.uk>
18
+    - Subsequent tidyup + testing etc
19
+Author: Krzysztof 'Mad Max' Laska - <madmax at riders.pl>
20
+    - Polish Translation.
21
+
22
+
23
+
24
+The Initial Developer of the Original postfixadmin Code is Mischa Peters.
25
+Portions created by Mischa Peters are Copyright (c) 2002, 2003, 2004.
26
+All Rights Reserved.
27
+
28
+REQUIREMENTS
29
+
30
+o SquirrelMail 1.4x
31
+
32
+o A working Mail-System "Virtual Domains and Users with postfix+Courier-IMAP+MySQL" (or PostgreSQL) See http://high5.net/howto/
33
+
34
+o POSTFIXADMIN version 2.2.0 or higher. See http://sf.net/projects/postfixadmin
35
+
36
+o This plugin only uses the postfixadmin database
37
+
38
+o Pear MDB2 database abstraction layer - see http://pear.php.net 
39
+
40
+o PHP installation with register globals TURNED OFF (huraren on IRC reports that the MDB2 driver isn't happy with it turned on)
41
+
42
+INSTALLATION
43
+
44
+See the included file INSTALL
45
+
46
+BUGS
47
+
48
+o Probably vulnerable to cross site scripting, certainly when setting the vacation message.
49
+
50
+o There may be some remaining SQL injection holes.
51
+
52
+TODO
53
+
54
+-Code Cleanup
55
+-Tranlation
56
+
57
+
58
+TRANSLATIONS
59
+
60
+Translations are welcome! Send the *.po-File to: david@NO.codepoets.SPAM.co.uk
61
+
62
+
63
+ACKNOWLEDGMENTS
64
+
65
+Thanks to the SquirrelMail team for building such a great app and
66
+for all the work they do to keep it running.
67
+
68
+Thanks to high5.net for writing the great Postfixadmin tool
69
+
70
+

+ 44
- 0
postfixadmin/postfixadmin-3.0/ADDITIONS/squirrelmail-plugin/common.php View File

@@ -0,0 +1,44 @@
1
+<?php
2
+// vim:ts=4:sw=4:et
3
+ini_set('include_path', get_include_path() . ':' . dirname(__FILE__));
4
+
5
+@include_once('Zend/Version.php');
6
+if(!class_exists('Zend_Version', false)) {
7
+	die("Zend Framework not found. Please check the INSTALL File.");
8
+}
9
+chdir("..");
10
+
11
+
12
+if (!defined('SM_PATH')) 
13
+{
14
+    define('SM_PATH','../');
15
+}
16
+include_once(dirname(__FILE__)  . '/config.php');
17
+include_once(dirname(__FILE__) . '/functions.inc.php');
18
+include_if_exists(dirname(__FILE__) . '/../include/validate.php');
19
+if (file_exists(dirname(__FILE__) . '/../include/validate.php')) 
20
+{
21
+    include_once(dirname(__FILE__) . '/include/validate.php');
22
+}
23
+else { 
24
+    include_if_exists(SM_PATH . 'src/validate.php');
25
+}
26
+include_once(SM_PATH . 'functions/page_header.php');
27
+include_once(SM_PATH . 'functions/display_messages.php');
28
+include_once(SM_PATH . 'functions/imap.php');
29
+include_if_exists(SM_PATH . 'functions/array.php');
30
+if (file_exists(SM_PATH . 'src/load_prefs.php'))
31
+{
32
+    include_once(SM_PATH . 'src/load_prefs.php');
33
+}
34
+else {
35
+    include_if_exists(SM_PATH . 'include/load_prefs.php');
36
+}
37
+// overwrite squirrelmail's content type to utf8...
38
+header("Content-Type: text/html; charset=utf8");
39
+
40
+
41
+//global $VACCONFMESSAGE;
42
+bindtextdomain('postfixadmin', dirname(__FILE__) . '/postfixadmin/locale');
43
+textdomain('postfixadmin');
44
+

+ 22
- 0
postfixadmin/postfixadmin-3.0/ADDITIONS/squirrelmail-plugin/config.php.sample View File

@@ -0,0 +1,22 @@
1
+<?php
2
+
3
+$CONF = array();
4
+$CONF['xmlrpc_url'] = 'http://postfixadmin.local/postfixadmin/xmlrpc.php';
5
+
6
+// Virtual Vacation
7
+// If you use virtual vacation for you mailbox users set this to 'true'.
8
+// NOTE: Make sure that you install the vacation module!!
9
+
10
+//$AllowVacation = true;    // true or false
11
+global $AllowVacation;
12
+$AllowVacation = true;
13
+
14
+// Change Password
15
+// Enables user to change the POP3/IMAP Password.
16
+//$AllowChangePass = true;    // true or false
17
+global $AllowChangePass;
18
+$AllowChangePass = true;
19
+
20
+// Minimum password length - set to Zero to not care, otherwise the number of 
21
+// characters a password must be longer than.
22
+$CONF['min_password_length'] = 5;

+ 20
- 0
postfixadmin/postfixadmin-3.0/ADDITIONS/squirrelmail-plugin/debian/README.Debian View File

@@ -0,0 +1,20 @@
1
+Squirrelmail PostfixAdmin Plugin for Debian
2
+===========================================
3
+
4
+After installing the package, you will need to :
5
+
6
+1) Edit the config.inc.php file to point to the PostfixAdmin server.
7
+
8
+2) Ensure the xmlrpc interface is available and enabled on the Postfixadmin server
9
+
10
+3) Run the squirrelmail-configure script.
11
+
12
+Where to get help
13
+=================
14
+
15
+See http://squirrelmail-postfixadmin.palepurple.co.uk
16
+
17
+Try also : david [at] pale purple dot co dot uk
18
+
19
+Or #postfixadmin on irc.freenode.net might be a good bet.
20
+

+ 27
- 0
postfixadmin/postfixadmin-3.0/ADDITIONS/squirrelmail-plugin/debian/changelog View File

@@ -0,0 +1,27 @@
1
+squirrelmail-postfixadmin (2.3.0) stable; urgency=low
2
+
3
+  * Using XMLRPC backend (no SQL here)
4
+
5
+ -- David Goodwin <david.goodwin@palepurple.co.uk>  Mon, 01 Feb 2010 09:56:00 +0000
6
+
7
+squirrelmail-postfixadmin (2.2.0) stable; urgency=low
8
+
9
+  * Changed DB backend to use prepared statements
10
+  * Changed vacation handling to match that of Postfixadmin (vacation.active
11
+    etc)
12
+  * Changed vacation page to support UTF8
13
+
14
+ -- David Goodwin <david.goodwin@palepurple.co.uk>  Wed, 20 Aug 2008 15:25:00 +0000
15
+
16
+squirrelmail-postfixadmin (2.1.1-1) stable; urgency=low
17
+
18
+  * Add NL language support
19
+  * Better db error logging (e.g. if wrong mdb2 driver specified etc)
20
+
21
+ -- David Goodwin <david.goodwin@palepurple.co.uk>  Wed, 12 Dec 2007 16:00:00 +0000
22
+
23
+squirrelmail-postfixadmin (2.1.0-1) stable; urgency=low
24
+
25
+  * Initial release.
26
+
27
+ -- David Goodwin <david.goodwin@palepurple.co.uk>  Thu,  8 Nov 2007 20:00:00 +0000

+ 1
- 0
postfixadmin/postfixadmin-3.0/ADDITIONS/squirrelmail-plugin/debian/conffiles View File

@@ -0,0 +1 @@
1
+/etc/squirrelmail/plugins/postfixadmin-config.php

+ 19
- 0
postfixadmin/postfixadmin-3.0/ADDITIONS/squirrelmail-plugin/debian/control View File

@@ -0,0 +1,19 @@
1
+Source: squirrelmail-postfixadmin
2
+Section: mail
3
+Priority: optional
4
+Maintainer: David Goodwin <david.goodwin@palepurple.co.uk>
5
+Standards-Version: 3.6.1
6
+
7
+Package: squirrelmail-postfixadmin
8
+Architecture: all
9
+Depends: squirrelmail, php-pear
10
+Suggests: postfixadmin
11
+Description: Plugin for Squirrelmail to integrate with Postfixadmin
12
+ Postfixadmin is a web based interface for managing mail domains 
13
+ and users. This package integrates Squirrelmail with it. 
14
+ Users can change their password, forwarding and vacation settings
15
+ from within Squirrelmail when this package is installed, and 
16
+ enabled through the ./squirrelmail-configure command.
17
+ .
18
+ For further information see 
19
+ http://squirrelmail-postfixadmin.palepurple.co.uk

+ 11
- 0
postfixadmin/postfixadmin-3.0/ADDITIONS/squirrelmail-plugin/debian/copyright View File

@@ -0,0 +1,11 @@
1
+This package was debianized by David Goodwin <david@palepurple.co.uk>
2
+2007/11/08
3
+
4
+It was downloaded from: http://squirremail-postfixadmin.palepurple.co.uk
5
+
6
+Upstream Author(s): n/a
7
+
8
+Copyright:
9
+    Copyright (C) 2007+ by David Goodwin <david@palepurple.co.uk>
10
+
11
+License: GPL v2+

+ 4
- 0
postfixadmin/postfixadmin-3.0/ADDITIONS/squirrelmail-plugin/debian/docs View File

@@ -0,0 +1,4 @@
1
+LICENSE.txt
2
+README
3
+INSTALL
4
+debian/README.Debian

+ 1
- 0
postfixadmin/postfixadmin-3.0/ADDITIONS/squirrelmail-plugin/debian/files View File

@@ -0,0 +1 @@
1
+squirrelmail-postfixadmin_2.2.0_all.deb mail optional

+ 3
- 0
postfixadmin/postfixadmin-3.0/ADDITIONS/squirrelmail-plugin/debian/postfixadmin-squirrelmail.dirs View File

@@ -0,0 +1,3 @@
1
+usr/share/squirrelmail/plugins/postfixadmin
2
+usr/share/doc/squirrelmail-postfixadmin
3
+etc/squirrelmail/plugins

+ 5
- 0
postfixadmin/postfixadmin-3.0/ADDITIONS/squirrelmail-plugin/debian/postinst View File

@@ -0,0 +1,5 @@
1
+#!/bin/sh
2
+
3
+echo "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
4
+echo "WARNING: You need to read /usr/share/doc/squirrelmail-postfixadmin/README.Debian!"
5
+echo "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"

+ 56
- 0
postfixadmin/postfixadmin-3.0/ADDITIONS/squirrelmail-plugin/debian/rules View File

@@ -0,0 +1,56 @@
1
+#!/usr/bin/make -f
2
+# debian/rules makefile for squirrelmail
3
+
4
+# Uncomment this to turn on verbose mode.
5
+#export DH_VERBOSE=1
6
+
7
+build: build-stamp
8
+build-stamp:
9
+	dh_testdir
10
+
11
+clean:
12
+	dh_testdir
13
+	dh_testroot
14
+	dh_clean
15
+
16
+install: build
17
+	$(checkdir)
18
+	dh_testdir
19
+	dh_testroot
20
+	dh_clean -k
21
+	dh_installdirs
22
+	dh_install
23
+	mkdir -p debian/tmp/usr/share/squirrelmail/plugins/postfixadmin
24
+	cp -a *.php version debian/tmp/usr/share/squirrelmail/plugins/postfixadmin
25
+	cp -a locale debian/tmp/usr/share/squirrelmail/plugins/postfixadmin
26
+	cp -a po debian/tmp/usr/share/squirrelmail/plugins/postfixadmin
27
+	mkdir -p debian/tmp/etc/squirrelmail/plugins/
28
+	cp -a *.sample debian/tmp/etc/squirrelmail/plugins/postfixadmin-config.php
29
+	mkdir -p debian/tmp/DEBIAN
30
+	cp debian/postinst debian/tmp/DEBIAN/postinst
31
+	chmod 555 debian/tmp/DEBIAN/postinst
32
+	ln -s /etc/squirrelmail/plugins/postfixadmin-config.php debian/tmp/usr/share/squirrelmail/plugins/postfixadmin/config.php
33
+	find debian/tmp -name .svn | xargs -r rm -r
34
+
35
+# Build architecture-independent files here.
36
+binary-indep: build install
37
+	dh_testdir
38
+	dh_testroot
39
+	dh_installdebconf	
40
+	dh_installdocs -X.svn
41
+	dh_installexamples
42
+	dh_installman
43
+	dh_installcron
44
+	dh_link
45
+	dh_compress
46
+	dh_fixperms -X/var
47
+	dh_installdeb
48
+	dh_gencontrol
49
+	dh_md5sums
50
+	dh_builddeb
51
+
52
+# Build architecture-dependent files here.
53
+binary-arch:
54
+
55
+binary: binary-indep binary-arch
56
+.PHONY: build clean binary-indep binary-arch binary install

+ 102
- 0
postfixadmin/postfixadmin-3.0/ADDITIONS/squirrelmail-plugin/functions.inc.php View File

@@ -0,0 +1,102 @@
1
+<?php
2
+/**
3
+ * Postfixadmin (http://postfixadmin.sf.net) integration with Squirrelmail.
4
+ * See http://squirrelmail-postfixadmin.palepurple.co.uk
5
+ * @author David Goodwin and many others
6
+ */
7
+
8
+
9
+function do_header() {
10
+    global $color;
11
+    displayPageHeader($color, 'None');
12
+}
13
+
14
+function do_footer() {
15
+    echo "</body></html>";
16
+}
17
+
18
+function _display_password_form() {
19
+    bindtextdomain('postfixadmin', SM_PATH . 'plugins/postfixadmin/locale');
20
+    textdomain('postfixadmin');
21
+    do_header('Postfixadmin Squirrelmail - Login');
22
+    echo _('The PostfixAdmin plugin needs your current mailbox password');
23
+    echo "<form action='' method='post'>";
24
+    echo _('Password for');
25
+    echo " " . $_SESSION['username'] . " :"; 
26
+    echo "<input type='password' name='password' value=''>";
27
+    echo "<input type='submit' value='" . _('Submit') . "'></form>";
28
+    do_footer();
29
+}
30
+
31
+/**
32
+ * This returns a Zend_XmlRpc_Client instance - unless we can't log you in...
33
+ */
34
+function get_xmlrpc() {
35
+    global $CONF;
36
+    require_once('Zend/XmlRpc/Client.php');
37
+    $client = new Zend_XmlRpc_Client($CONF['xmlrpc_url']);
38
+    $http_client = $client->getHttpClient();
39
+    $http_client->setCookieJar();
40
+
41
+    $login_object = $client->getProxy('login');
42
+
43
+    if(empty($_SESSION['password'])) {
44
+        if(empty($_POST['password'])) {
45
+            _display_password_form();
46
+            exit(0);
47
+        }
48
+        else {
49
+            try {
50
+                $success = $login_object->login($_SESSION['username'], $_POST['password']);
51
+            }
52
+            catch(Exception $e) {
53
+                //var_dump($client->getHttpClient()->getLastResponse()->getBody());
54
+                error_log("Failed to login to xmlrpc instance - " . $e->getMessage());
55
+                die('Failed to login to xmlrpc instance');
56
+            }
57
+            if($success) {
58
+                $_SESSION['password'] = $_POST['password'];
59
+                // reload the current page as a GET request.
60
+                header("Location: {$_SERVER['REQUEST_URI']}");
61
+                exit(0);
62
+            }
63
+            else {
64
+                _display_password_form();
65
+                exit(0);
66
+            }
67
+        }
68
+    }
69
+    else {
70
+        $success = $login_object->login($_SESSION['username'], $_SESSION['password']);
71
+    }
72
+
73
+    if(!$success) {
74
+        unset($_SESSION['password']);
75
+        die("Invalid details cached... refresh this page and re-enter your mailbox password");
76
+    }
77
+    return $client;
78
+}
79
+
80
+function include_if_exists($filename) {
81
+    if(file_exists($filename)) {
82
+        include_once($filename);
83
+    }
84
+    return;
85
+}
86
+global $optmode;
87
+$optmode = 'display';
88
+
89
+//
90
+// check_email
91
+// Action: Checks if email is valid and returns TRUE if this is the case.
92
+// Call: check_email (string email)
93
+//
94
+function check_email($email) {
95
+    $return = filter_var($email, FILTER_VALIDATE_EMAIL);
96
+    if($return === false) {
97
+        return false;
98
+    }
99
+    return true;
100
+}
101
+
102
+

+ 27
- 0
postfixadmin/postfixadmin-3.0/ADDITIONS/squirrelmail-plugin/index.php View File

@@ -0,0 +1,27 @@
1
+<?php
2
+
3
+/****************************************************************************************
4
+
5
+    Author ......... Florian Kimmerl
6
+    Contact ........ info@spacekoeln.de
7
+    Home Site ...... http://www.spacekoeln.de/
8
+    Program ........ postfixadmin
9
+    Version ........ 0.3-1.4
10
+    Purpose ........ Allows you to change your postfixadmin settings within squirrelmail
11
+
12
+ /**
13
+ * index.php
14
+ *
15
+ * Copyright (c) 1999-2003 The SquirrelMail Project Team
16
+ * Licensed under the GNU GPL. For full terms see the file COPYING.
17
+ *
18
+ * This file simply takes any attempt to view source files and sends those
19
+ * people to the login screen. At this point no attempt is made to see if
20
+ * the person is logged or not.
21
+ *
22
+ *
23
+****************************************************************************************/
24
+
25
+header("Location: ../../index.php");
26
+
27
+?>

+ 6
- 0
postfixadmin/postfixadmin-3.0/ADDITIONS/squirrelmail-plugin/locale/build.sh View File

@@ -0,0 +1,6 @@
1
+#!/bin/bash
2
+
3
+for f in $(find . -name postfixadmin.po)
4
+do
5
+    msgfmt -o $(dirname $f)/postfixadmin.mo $f
6
+done

BIN
postfixadmin/postfixadmin-3.0/ADDITIONS/squirrelmail-plugin/locale/cs_CZ/LC_MESSAGES/postfixadmin.mo View File


+ 132
- 0
postfixadmin/postfixadmin-3.0/ADDITIONS/squirrelmail-plugin/locale/cs_CZ/LC_MESSAGES/postfixadmin.po View File

@@ -0,0 +1,132 @@
1
+# SOME DESCRIPTIVE TITLE.
2
+# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER
3
+# This file is distributed under the same license as the PACKAGE package.
4
+# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
5
+#
6
+msgid ""
7
+msgstr ""
8
+"Project-Id-Version: PACKAGE VERSION\n"
9
+"POT-Creation-Date: 2004-01-29 17:35+0100\n"
10
+"PO-Revision-Date: 2007-07-20 20:46+0100\n"
11
+"Last-Translator: Michael Heca <michael.heca@gmail.com>\n"
12
+"Language-Team: LANGUAGE <LL@li.org>\n"
13
+"MIME-Version: 1.0\n"
14
+"Content-Type: text/plain; charset=iso-8859-2\n"
15
+"Content-Transfer-Encoding: 8bit\n"
16
+
17
+#: setup.php
18
+msgid "Forwarding"
19
+msgstr "Pøesmìrování"
20
+
21
+msgid "Here you can create and edit E-Mail forwards."
22
+msgstr "Zde mù¾ete vytvoøit a nastavit pøesmìrování"
23
+
24
+msgid "Set an OUT OF OFFICE message or auto responder for your mail."
25
+msgstr "Zde mù¾ete nastavit automatickou odpovìd, pokud nebudete k zasti¾ení."
26
+
27
+msgid "Change your mailbox password."
28
+msgstr "Zmìnít heslo k Va¹emu e-mailovému úètu"
29
+
30
+#: postfixadmin_changepass.php
31
+msgid "Alias"
32
+msgstr "Úèet"
33
+
34
+msgid "Change Password"
35
+msgstr "Zmìnit heslo"
36
+
37
+msgid "Change your login password"
38
+msgstr "Zmìnít heslo k Va¹emu e-mailovému úètu"
39
+
40
+#: postfixadmin_forward.php
41
+msgid "Edit Alias"
42
+msgstr "Editace adresy pro pøesmìrování"
43
+
44
+msgid "Edit an alias* for your domain.<br />One entry per line."
45
+msgstr "Editace pøesmìrování pro Vá¹ úèet. <br/> Ka¾dá adresa na novém øádku."
46
+
47
+msgid "The email address that you have entered is not valid:"
48
+msgstr "Zadaná e-mailová adresa je chybná:"
49
+
50
+msgid "Unable to locate alias!"
51
+msgstr "Neni mo¾né nalézt úèet!"
52
+
53
+msgid "Unable to modify the alias!"
54
+msgstr "Není mo¾né zmìnit úèet!"
55
+
56
+msgid "*Additional forward-aliase always recieve messages BBC!"
57
+msgstr "Dal¹í aliasy dostanou e-mail jako BBC!"
58
+
59
+msgid "Alias successfully changend!"
60
+msgstr "Pøesmìrování bylo zmìnìno!"
61
+
62
+msgid "To remove an alias, simply delete it's line from the text box."
63
+msgstr "Pro odstranení pøesmìrování sma¾te v¹echny øádky v textovém boxu."
64
+
65
+#: postfixadmin_vacation.php
66
+msgid "Auto Response"
67
+msgstr "Automatická odpovìï"
68
+
69
+msgid "Going Away"
70
+msgstr "Jsem mimo"
71
+
72
+msgid "Coming Back"
73
+msgstr "Jsem zpìt"
74
+
75
+msgid "Options"
76
+msgstr "Nastavení"
77
+
78
+msgid "Out of Office"
79
+msgstr "Mimo kanceláø"
80
+
81
+msgid "Subject"
82
+msgstr "Pøedmìt"
83
+
84
+msgid "Body"
85
+msgstr "Tìlo mailu"
86
+
87
+msgid "Your auto response has been removed!"
88
+msgstr "Va¹e automatická odpovìï byla odstranìna!"
89
+
90
+msgid "Your auto response has been set!"
91
+msgstr "Va¹e automatická odpovìï byla nastavena!"
92
+
93
+msgid "You already have an auto response configured!"
94
+msgstr "U¾ máte nastavenu automatickou odpovìï!"
95
+
96
+#: postfixadmin_changepass.php:81
97
+#: postfixadmin_changepass.php:87
98
+msgid "The passwords that you supplied don't match!<br />Or are empty!"
99
+msgstr "Zadaná hesla nejsou stejná a nebo jsou prázdná!"
100
+
101
+#: postfixadmin_forward.php:70
102
+#: postfixadmin_forward.php:152
103
+msgid "To"
104
+msgstr "Komu"
105
+
106
+#: postfixadmin_changepass.php:101
107
+msgid "Unable to change your password!"
108
+msgstr "Není mo¾né zmìnit heslo!"
109
+
110
+#: postfixadmin_changepass.php:75
111
+msgid "You didn't supply your current password!"
112
+msgstr "Stávající heslo neodpovídá!"
113
+
114
+#: postfixadmin_changepass.php:96
115
+msgid "Your password has been changed!"
116
+msgstr "Va¹e heslo bylo zmìnìno!"
117
+
118
+msgid "Password current"
119
+msgstr "Stávající heslo"
120
+
121
+msgid "Password new"
122
+msgstr "Nové heslo"
123
+
124
+msgid "Password new again"
125
+msgstr "Nové heslo znovu"
126
+
127
+msgid "Please sign out and log back again with your new password!"
128
+msgstr "Prosím odhla¹te se a pøihla¹te se s novým heslem!"
129
+
130
+msgid "I will be away from <date> until <date>. For urgent matters you can contact <contact person>."
131
+msgstr "Nebudy k zasti¾ení od <date> do <date>. Pro naléhané po¾adavky prosím kontaktujte <contact person>."
132
+

BIN
postfixadmin/postfixadmin-3.0/ADDITIONS/squirrelmail-plugin/locale/da_DK/LC_MESSAGES/postfixadmin.mo View File


+ 127
- 0
postfixadmin/postfixadmin-3.0/ADDITIONS/squirrelmail-plugin/locale/da_DK/LC_MESSAGES/postfixadmin.po View File

@@ -0,0 +1,127 @@
1
+# Danish translation for Squirrelmail Plugin Postfixadmin.
2
+# Copyright (C) 2004 Florian Kimmerl, 2007 David Goodwin
3
+# This file is distributed under the same license as the Squirrelmail Plugin Postfixadmin package.
4
+# Jesper R. Meyer <jrm@upthere.dk>, 2007.
5
+#
6
+#, fuzzy
7
+msgid ""
8
+msgstr ""
9
+"Project-Id-Version: 0.4.3\n"
10
+"POT-Creation-Date: 2004-01-29 17:35+0100\n"
11
+"PO-Revision-Date: 2007-11-09 16:07+0100\n"
12
+"Last-Translator: JESPER MEYER <jrm@upthere.dk>\n"
13
+"Language-Team: DANISH <LL@li.org>\n"
14
+"MIME-Version: 1.0\n"
15
+"Content-Type: text/plain; charset=UTF-8\n"
16
+"Content-Transfer-Encoding: 8bit\n"
17
+
18
+#: setup.php
19
+msgid "Forwarding"
20
+msgstr "Videresending"
21
+
22
+msgid "Here you can create and edit E-Mail forwards."
23
+msgstr "Her kan du oprette og ændre email-videresendinger."
24
+
25
+msgid "Set an OUT OF OFFICE message or auto responder for your mail."
26
+msgstr "Tilføj en 'ikke tilstede' besked eller et autosvar til din emailadresse."
27
+
28
+msgid "Change your mailbox password."
29
+msgstr "Ændre adgangskoden til din postboks"
30
+
31
+#: postfixadmin_changepass.php
32
+msgid "Alias"
33
+msgstr "Alias"
34
+
35
+msgid "Change Password"
36
+msgstr "Ændre adgangskode"
37
+
38
+msgid "Change your login password"
39
+msgstr "Ændre din login-adgangskode"
40
+
41
+#: postfixadmin_forward.php
42
+msgid "Edit Alias"
43
+msgstr "Rediger alias"
44
+
45
+msgid "Edit an alias* for your domain.<br />One entry per line."
46
+msgstr "Rediger et alias* for dit domæne.<br />En modtager pr. linje."
47
+
48
+msgid "The email address that you have entered is not valid:"
49
+msgstr "Emailadressen du angav er ugyldig"
50
+
51
+msgid "Unable to locate alias!"
52
+msgstr "Aliaset eksistere ikke!"
53
+
54
+msgid "Unable to modify the alias!"
55
+msgstr "Kunne ikke ændre aliaset!"
56
+
57
+msgid "*Additional forward-aliase always recieve messages BBC!"
58
+msgstr "*Eksta vidersendingsalias modtager altid meddelelser BCC!"
59
+
60
+msgid "Alias successfully changend!"
61
+msgstr "Alias ændret!"
62
+
63
+#: postfixadmin_vacation.php
64
+msgid "Auto Response"
65
+msgstr "Autosvar"
66
+
67
+msgid "Going Away"
68
+msgstr "Tager afsted"
69
+
70
+msgid "Coming Back"
71
+msgstr "Kommer tilbage"
72
+
73
+msgid "Options"
74
+msgstr "Indstillinger"
75
+
76
+msgid "Out of Office"
77
+msgstr "Ikke tilstede"
78
+
79
+msgid "Subject"
80
+msgstr "Emne"
81
+
82
+msgid "Body"
83