diff --git a/integrations/cloudron/DESCRIPTION.md b/integrations/cloudron/DESCRIPTION.md
new file mode 100644
index 000000000..ff7fecc6c
--- /dev/null
+++ b/integrations/cloudron/DESCRIPTION.md
@@ -0,0 +1,22 @@
+This app packages SnappyMail 2.7.3.
+
+SnappyMail is a simple, modern, lightweight & fast web-based email client.
+
+### Features
+ * Privacy/GDPR friendly
+ * Modern user (dark mode) interface.
+ * Mobile booting with only ~144 KB download
+ * Complete support of IMAP and SMTP protocols including SSL and STARTTLS.
+ * Sieve scripts (Filters and vacation message).
+ * Minimalistic resources requirements.
+ * Direct access to mail server is used (mails are not stored locally on web server).
+ * Allows for adding multiple accounts to primary one.
+ * Additional identities.
+ * Administrative panel for configuring main options.
+ * Really simple installation and update (the product is updated from admin panel).
+ * Managing folders list.
+ * Simple look'n'feel customization.
+ * Extending functionality with plugins installed through admin panel.
+ * Perfect rendering of complex HTML mails.
+ * Drag'n'drop for mails and attachments.
+ * Keyboard shortcuts support.
diff --git a/integrations/cloudron/Dockerfile b/integrations/cloudron/Dockerfile
new file mode 100644
index 000000000..0cc791fba
--- /dev/null
+++ b/integrations/cloudron/Dockerfile
@@ -0,0 +1,38 @@
+FROM cloudron/base:3.0.0@sha256:455c70428723e3a823198c57472785437eb6eab082e79b3ff04ea584faf46e92
+
+RUN mkdir -p /app/code
+WORKDIR /app/code
+
+# If you change the extraction below, be sure to test on scaleway
+VERSION=2.7.3
+RUN wget https://github.com/the-djmaze/snappymail/releases/download/v${VERSION}/snappymail-${VERSION}.zip -O /tmp/snappymail.zip && \
+ unzip /tmp/snappymail.zip -d /app/code && \
+ rm /tmp/snappymail.zip && \
+ find /app/code/snappymail -type d -exec chmod 755 {} \; && \
+ find /app/code/snappymail -type f -exec chmod 644 {} \; && \
+ rm -rf /app/code/data && ln -s /app/data /app/code/data && \
+ chown -R www-data:www-data /app/code/snappymail
+
+# configure apache
+RUN rm /etc/apache2/sites-enabled/*
+RUN sed -e 's,^ErrorLog.*,ErrorLog "|/bin/cat",' -i /etc/apache2/apache2.conf
+COPY apache/mpm_prefork.conf /etc/apache2/mods-available/mpm_prefork.conf
+
+RUN a2disconf other-vhosts-access-log
+ADD apache/snappymail.conf /etc/apache2/sites-enabled/snappymail.conf
+RUN echo "Listen 8000" > /etc/apache2/ports.conf
+
+# mod_php config
+RUN a2enmod rewrite
+RUN crudini --set /etc/php/7.4/apache2/php.ini PHP upload_max_filesize 25M && \
+ crudini --set /etc/php/7.4/apache2/php.ini PHP post_max_size 25M && \
+ crudini --set /etc/php/7.4/apache2/php.ini Session session.save_path /run/snappymail/sessions && \
+ crudini --set /etc/php/7.4/apache2/php.ini Session session.gc_probability 1 && \
+ crudini --set /etc/php/7.4/apache2/php.ini Session session.gc_divisor 100
+
+RUN ln -s /app/data/php.ini /etc/php/7.4/apache2/conf.d/99-cloudron.ini && \
+ ln -s /app/data/php.ini /etc/php/7.4/cli/conf.d/99-cloudron.ini
+
+ADD start.sh /app/code/start.sh
+
+CMD [ "/app/code/start.sh" ]
diff --git a/integrations/virtualmin/snappymail.pl b/integrations/virtualmin/snappymail.pl
new file mode 100644
index 000000000..25c69ffc0
--- /dev/null
+++ b/integrations/virtualmin/snappymail.pl
@@ -0,0 +1,405 @@
+# This script is probably broken and not tested!
+# https://forum.virtualmin.com/t/add-snappymail-to-install-scripts/112560
+
+# script_snappymail_desc()
+sub script_snappymail_desc
+{
+return "SnappyMail";
+}
+
+sub script_snappymail_uses
+{
+return ( "php" );
+}
+
+sub script_snappymail_longdesc
+{
+return "SnappyMail Webmail is a browser-based multilingual IMAP client with an application-like user interface";
+}
+
+# script_snappymail_versions()
+sub script_snappymail_versions
+{
+return ( "2.7.3" );
+}
+
+sub script_snappymail_version_desc
+{
+local ($ver) = @_;
+return &compare_versions($ver, "2.7") >= 0 ? "$ver" : "$ver (Un-supported)";
+}
+
+sub script_snappymail_category
+{
+return "Email";
+}
+
+sub script_snappymail_php_modules
+{
+local ($dbtype, $dbname) = split(/_/, $opts->{'db'}, 2);
+local @modules = ( "zlib", "mbstring" );
+push(@modules, $dbtype eq "mysql" ? "pdo_mysql" : $dbtype eq "sqlite" ? "pdo_sqlite" : "pdo_pgsql");
+return @modules;
+}
+
+sub script_snappymail_php_optional_modules
+{
+return ( "gd", "openssl", "sockets", "xxtea", "curl", "intl", "ldap", "zip", "gmagick", "imagick" );
+}
+
+sub script_snappymail_dbs
+{
+return ("mysql", "postgres", "sqlite");
+}
+
+# script_snappymail_php_vars(&domain)
+# Returns an array of extra PHP variables needed for this script
+sub script_snappymail_php_vars
+{
+return ([ 'memory_limit', '64M', '+' ],
+ [ 'max_execution_time', 300, '+' ],
+ [ 'file_uploads', 'On' ],
+ [ 'upload_max_filesize', '25M', '+' ],
+ [ 'post_max_size', '25M', '+' ],
+ [ 'session.auto_start', 'Off' ],
+ [ 'mbstring.func_overload', 'Off' ]);
+}
+
+
+sub script_snappymail_php_vers
+{
+return ( 7 );
+}
+
+sub script_snappymail_release
+{
+return 3; # For folders path fix
+}
+
+sub script_snappymail_php_fullver
+{
+return "7.4";
+}
+
+# script_snappymail_params(&domain, version, &upgrade-info)
+# Returns HTML for table rows for options for installing PHP-NUKE
+sub script_snappymail_params
+{
+local ($d, $ver, $upgrade) = @_;
+local $rv;
+local $hdir = &public_html_dir($d, 1);
+if ($upgrade) {
+ # Options are fixed when upgrading
+ local ($dbtype, $dbname) = split(/_/, $upgrade->{'opts'}->{'db'}, 2);
+ $rv .= &ui_table_row("Database for SnappyMail preferences", $dbname);
+ local $dir = $upgrade->{'opts'}->{'dir'};
+ $dir =~ s/^$d->{'home'}\///;
+ $rv .= &ui_table_row("Install directory", $dir);
+ }
+else {
+ # Show editable install options
+ local @dbs = &domain_databases($d, [ "mysql", "postgres", "sqlite" ]);
+ $rv .= &ui_table_row("Database for SnappyMail preferences",
+ &ui_database_select("db", undef, \@dbs, $d, "snappymail"));
+ $rv .= &ui_table_row("Install sub-directory under $hdir",
+ &ui_opt_textbox("dir", &substitute_scriptname_template("snappymail", $d), 30, "At top level"));
+ }
+return $rv;
+}
+
+# script_snappymail_parse(&domain, version, &in, &upgrade-info)
+# Returns either a hash ref of parsed options, or an error string
+sub script_snappymail_parse
+{
+local ($d, $ver, $in, $upgrade) = @_;
+if ($upgrade) {
+ # Options are always the same
+ return $upgrade->{'opts'};
+ }
+else {
+ local $hdir = &public_html_dir($d, 0);
+ $in{'dir_def'} || $in{'dir'} =~ /\S/ && $in{'dir'} !~ /\.\./ ||
+ return "Missing or invalid installation directory";
+ local $dir = $in{'dir_def'} ? $hdir : "$hdir/$in{'dir'}";
+ local ($newdb) = ($in->{'db'} =~ s/^\*//);
+ return { 'db' => $in->{'db'},
+ 'newdb' => $newdb,
+ 'dir' => $dir,
+ 'path' => $in{'dir_def'} ? "/" : "/$in{'dir'}", };
+ }
+}
+
+# script_snappymail_check(&domain, version, &opts, &upgrade-info)
+# Returns an error message if a required option is missing or invalid
+sub script_snappymail_check
+{
+local ($d, $ver, $opts, $upgrade) = @_;
+$opts->{'dir'} =~ /^\// || return "Missing or invalid install directory";
+$opts->{'db'} || return "Missing database";
+if (-r "$opts->{'dir'}/config/db.inc.php") {
+ return "SnappyMail appears to be already installed in the selected directory";
+ }
+local ($dbtype, $dbname) = split(/_/, $opts->{'db'}, 2);
+local $clash = &find_database_table($dbtype, $dbname, "system|filestore|contacts|users");
+$clash && return "SnappyMail appears to be already using the selected database (table $clash)";
+return undef;
+}
+
+# script_snappymail_files(&domain, version, &opts, &upgrade-info)
+# Returns a list of files needed by SnappyMail, each of which is a hash ref
+# containing a name, filename and URL
+sub script_snappymail_files
+{
+local ($d, $ver, $opts, $upgrade) = @_;
+local @files = ( { 'name' => "source",
+ 'file' => "snappymail-$ver.tar.gz",
+ 'url' => "https://github.com/the-djmaze/snappymail/releases/download/v${ver}/snappymail-${ver}.tar.gz" },
+ );
+return @files;
+}
+
+sub script_snappymail_commands
+{
+return ("tar", "gunzip");
+}
+
+# script_snappymail_install(&domain, version, &opts, &files, &upgrade-info)
+# Actually installs SnappyMail, and returns either 1 and an informational
+# message, or 0 and an error
+sub script_snappymail_install
+{
+local ($d, $version, $opts, $files, $upgrade) = @_;
+local ($out, $ex);
+
+# Create and get DB
+if ($opts->{'newdb'} && !$upgrade) {
+ local $err = &create_script_database($d, $opts->{'db'});
+ return (0, "Database creation failed : $err") if ($err);
+ }
+local ($dbtype, $dbname) = split(/_/, $opts->{'db'}, 2);
+local $dbuser = $dbtype eq "mysql" ? &mysql_user($d) : &postgres_user($d);
+local $dbpass = $dbtype eq "mysql" ? &mysql_pass($d) : &postgres_pass($d, 1);
+local $dbphptype = $dbtype eq "mysql" ? "mysql" : "psql";
+local $dbhost = &get_database_host($dbtype, $d);
+local $dberr = &check_script_db_connection($dbtype, $dbname, $dbuser, $dbpass);
+return (0, "Database connection failed : $dberr") if ($dberr);
+
+# Extract tar file to temp dir and copy to target
+local $temp = &transname();
+local $verdir = $ver;
+$verdir =~ s/-complete$//;
+local $err = &extract_script_archive($files->{'source'}, $temp, $d,
+ $opts->{'dir'}, "snappymail-$verdir");
+$err && return (0, "Failed to extract source : $err");
+
+if (!$upgrade) {
+ # Fix up the DB config file
+ local $dbcfileorig = "$opts->{'dir'}/config/db.inc.php.dist";
+ local $dbcfile = "$opts->{'dir'}/config/db.inc.php";
+ if (-r $dbcfileorig) {
+ ©_source_dest_as_domain_user($d, $dbcfileorig, $dbcfile);
+ local $lref = &read_file_lines_as_domain_user($d, $dbcfile);
+ foreach my $l (@$lref) {
+ if ($l =~ /^\$rcmail_config\['db_dsnw'\]\s+=/) {
+ $l = "\$rcmail_config['db_dsnw'] = 'mysql://$dbuser:".
+ &php_quotemeta($dbpass, 1).
+ "\@$dbhost/$dbname';";
+ }
+ elsif ($l =~ /^\$rcmail_config\['db_backend'\]\s+=/) {
+ $l = "\$rcmail_config['db_backend'] = 'db';";
+ }
+ }
+ &flush_file_lines_as_domain_user($d, $dbcfile);
+ }
+
+ # Figure out folder names
+ local %fmap;
+ $fmap{'drafts'} = $config{'drafts_folder'} || 'drafts';
+ $fmap{'sent'} = $config{'sent_folder'} || 'sent';
+ $fmap{'trash'} = $config{'trash_folder'} || 'sent';
+ local ($sdmode, $sdpath) = &get_domain_spam_delivery($d);
+ if (($sdmode == 6 || $sdmode == 4) && $sdpath) {
+ $fmap{'junk'} = $sdpath;
+ }
+ elsif ($sdmode == 1 && $sdpath =~ /^Maildir\/\.?(\S+)\/$/) {
+ $fmap{'junk'} = $1;
+ }
+
+ # Fix up the main config file
+ local $mcfileorig = "$opts->{'dir'}/config/main.inc.php.dist";
+ local $mcfile = "$opts->{'dir'}/config/main.inc.php";
+ if (!-r $mcfileorig) {
+ $mcfileorig = "$opts->{'dir'}/config/config.inc.php.sample";
+ $mcfile = "$opts->{'dir'}/config/config.inc.php";
+ }
+ ©_source_dest_as_domain_user($d, $mcfileorig, $mcfile);
+ local $lref = &read_file_lines_as_domain_user($d, $mcfile);
+ local $vuf = &get_mail_virtusertable();
+ local $added_vuf = 0;
+ foreach my $l (@$lref) {
+ if ($l =~ /^\$(rcmail_config|config)\['enable_caching'\]\s+=/) {
+ $l = "\$${1}['enable_caching'] = FALSE;";
+ }
+ if ($l =~ /^\$(rcmail_config|config)\['default_host'\]\s+=/) {
+ $l = "\$${1}['default_host'] = 'localhost';";
+ }
+ if ($l =~ /^\$(rcmail_config|config)\['default_port'\]\s+=/) {
+ $l = "\$${1}['default_port'] = 143;";
+ }
+ if ($l =~ /^\$(rcmail_config|config)\['smtp_server'\]\s+=/) {
+ $l = "\$${1}['smtp_server'] = 'localhost';";
+ }
+ if ($l =~ /^\$(rcmail_config|config)\['smtp_port'\]\s+=/) {
+ $l = "\$${1}['smtp_port'] = 25;";
+ }
+ if ($l =~ /^\$(rcmail_config|config)\['smtp_user'\]\s+=/) {
+ $l = "\$${1}['smtp_user'] = '%u';";
+ }
+ if ($l =~ /^\$(rcmail_config|config)\['smtp_pass'\]\s+=/) {
+ $l = "\$${1}['smtp_pass'] = '%p';";
+ }
+ if ($l =~ /^\$(rcmail_config|config)\['mail_domain'\]\s+=/) {
+ $l = "\$${1}['mail_domain'] = '$d->{'dom'}';";
+ }
+ if ($l =~ /^\$(rcmail_config|config)\['virtuser_file'\]\s+=/ && $vuf) {
+ $added_vuf = 1;
+ $l = "\$${1}['virtuser_file'] = '$vuf';";
+ }
+ if ($l =~ /^\$(rcmail_config|config)\['plugins'\]\s+=\s+array\(\s*$/) {
+ $l = "\$${1}['plugins'] = array('virtuser_file',";
+ }
+ elsif ($l =~ /^\$(rcmail_config|config)\['plugins'\]\s+=/) {
+ $l = "\$${1}['plugins'] = array('virtuser_file');";
+ }
+ if ($l =~ /^\$(rcmail_config|config)\['db_dsnw'\]\s+=/) {
+ $l = "\$${1}['db_dsnw'] = 'mysql://$dbuser:".
+ &php_quotemeta($dbpass, 1)."\@$dbhost/$dbname';";
+ }
+ if ($l =~ /^\$(rcmail_config|config)\['(\S+)_mbox'\]\s+=/ &&
+ $fmap{$2} && $fmap{$2} ne "*") {
+ $l = "\$${1}['${2}_mbox'] = '$fmap{$2}';";
+ }
+ }
+ if (!$added_vuf && $vuf) {
+ # Need to add virtuser_file directive, as no default exists
+ push(@$lref, "\$rcmail_config['virtuser_file'] = '$vuf';");
+ push(@$lref, "\$config['virtuser_file'] = '$vuf';");
+ }
+ &flush_file_lines_as_domain_user($d, $mcfile);
+
+ # Run SQL setup script
+ &require_mysql();
+ local $sqlfile;
+ if ($dbtype eq "mysql") {
+ $sqlfile = "$opts->{'dir'}/SQL/mysql.initial.sql";
+ }
+ else {
+ $sqlfile = "$opts->{'dir'}/SQL/postgres.initial.sql";
+ }
+ local ($ex, $out) = &mysql::execute_sql_file($dbname, $sqlfile,
+ $dbuser, $dbpass);
+ $ex && return (-1, "Failed to run database setup script : ".
+ "$out.");
+ }
+else {
+ # Create script of upgrade SQL to run, by extracting SQL from the old
+ # version onwards from mysql.update.sql
+ &require_mysql();
+ local $sqltemp = &transname();
+ &open_tempfile(SQLTEMP, ">$sqltemp", 0, 1);
+ open(SQLIN, "<$opts->{'dir'}/SQL/mysql.update.sql");
+ local $foundver = 0;
+ while() {
+ if (/Updates\s+from\s+version\s+(\S+)/ &&
+ &compare_versions("$1", $upgrade->{'version'}) >= 0) {
+ $foundver = 1;
+ }
+ if ($foundver) {
+ &print_tempfile(SQLTEMP, $_);
+ }
+ }
+ close(SQLIN);
+ &close_tempfile(SQLTEMP);
+ if ($foundver) {
+ local ($ex, $out) = &mysql::execute_sql_file($dbname, $sqltemp,
+ $dbuser, $dbpass);
+ $ex && return (-1, "Failed to run database date script : ".
+ "$out.");
+ }
+ &unlink_file($sqltemp);
+ }
+
+# Return a URL for the user
+local $url = &script_path_url($d, $opts);
+local $rp = $opts->{'dir'};
+$rp =~ s/^$d->{'home'}\///;
+return (1, "SnappyMail installation complete. It can be accessed at $url.", "Under $rp using $dbphptype database $dbname", $url);
+}
+
+# script_wordpress_db_conn_desc()
+# Returns a list of options for config file to update
+sub script_snappymail_db_conn_desc
+{
+my $conn_desc =
+ {
+ 'replace' => [ '\$(rcmail_config|config)\[[\'"]db_dsnw[\'"]\]\s*=\s*' =>
+ '\'$$sdbtype://$$sdbuser:$$sdbpass@$$sdbhost/$$sdbname\';' ],
+ 'func' => 'php_quotemeta',
+ 'func_params' => 1,
+ 'multi' => 1,
+ };
+my $db_conn_desc =
+ { 'config/config.inc.php' =>
+ {
+ 'dbtype' => $conn_desc,
+ 'dbuser' => $conn_desc,
+ 'dbpass' => $conn_desc,
+ 'dbhost' => $conn_desc,
+ 'dbname' => $conn_desc,
+ }
+ };
+return $db_conn_desc;
+}
+
+# script_snappymail_uninstall(&domain, version, &opts)
+# Un-installs a SnappyMail installation, by deleting the directory and database.
+# Returns 1 on success and a message, or 0 on failure and an error
+sub script_snappymail_uninstall
+{
+local ($d, $version, $opts) = @_;
+
+# Remove snappymail tables from the database
+&cleanup_script_database($d, $opts->{'db'}, "(.*)");
+
+# Take out the DB
+if ($opts->{'newdb'}) {
+ &delete_script_database($d, $opts->{'db'});
+ }
+
+# Remove the contents of the target directory
+local $derr = &delete_script_install_directory($d, $opts);
+return (0, $derr) if ($derr);
+
+return (1, "SnappyMail directory and tables deleted.");
+}
+
+# script_snappymail_latest(version)
+# Returns a URL and regular expression or callback func to get the version
+sub script_snappymail_latest
+{
+local ($ver) = @_;
+return ( "https://snappymail.eu/download/",
+ "snappymail-([0-9\\.]+).tar.gz" );
+}
+
+sub script_snappymail_site
+{
+return 'https://snappymail.eu/';
+}
+
+sub script_snappymail_gpl
+{
+return 1;
+}
+
+1;
diff --git a/release.php b/release.php
index e43fd8dd1..8dd38295b 100755
--- a/release.php
+++ b/release.php
@@ -87,12 +87,26 @@ if (!$gulp) {
$package = json_decode(file_get_contents('package.json'));
-// Update files that contain version
+/**
+ * Update files that contain version
+ */
+// cloudron
+$file = __DIR__ . '/integrations/cloudron/Dockerfile';
+file_put_contents($file, preg_replace('/ARG VERSION=[0-9.]+/', "VERSION={$package->version}", file_get_contents($file)));
+$file = __DIR__ . '/integrations/cloudron/DESCRIPTION.md';
+file_put_contents($file, preg_replace('/[^<]*', "{$package->version}<", file_get_contents($file)));
+// docker
+$file = __DIR__ . '/.docker/release/files/usr/local/include/application.ini';
+file_put_contents($file, preg_replace('/current = "[0-9.]+"/', "current = \"{$package->version}\"", file_get_contents($file)));
+// nextcloud
file_put_contents(__DIR__ . '/integrations/nextcloud/snappymail/VERSION', $package->version);
$file = __DIR__ . '/integrations/nextcloud/snappymail/appinfo/info.xml';
file_put_contents($file, preg_replace('/[^<]*', "{$package->version}<", file_get_contents($file)));
-$file = __DIR__ . '/.docker/release/files/usr/local/include/application.ini';
-file_put_contents($file, preg_replace('/current = "[0-9.]+"/', "current = \"{$package->version}\"", file_get_contents($file)));
+// virtualmin
+$file = __DIR__ . '/integrations/virtualmin/snappymail.pl';
+file_put_contents($file, preg_replace('/return \\( "[0-9]+\\.[0-9]+\\.[0-9]+" \\)/', "return ( \"{$package->version}\" )", file_get_contents($file)));
+
+
if (isset($options['set-version'])) {
exit;
}