From cacfd8c7fd1f6720f31200ba5b2ce5449cb95350 Mon Sep 17 00:00:00 2001 From: Varakh Date: Thu, 19 Dec 2019 00:12:03 +0100 Subject: [PATCH] Add mail support by adding msmtp for sending --- Dockerfile | 25 +++++++---- src/config/config-local.php.tpl | 12 +---- src/config/email.php.tpl | 13 ++++++ src/configure-mail.sh | 20 +++++++++ src/configure.php | 78 +++++++++++++++++++-------------- 5 files changed, 97 insertions(+), 51 deletions(-) create mode 100644 src/config/email.php.tpl create mode 100755 src/configure-mail.sh diff --git a/Dockerfile b/Dockerfile index b7624e3..2853738 100644 --- a/Dockerfile +++ b/Dockerfile @@ -67,27 +67,33 @@ RUN chmod -x /wait-for.sh && \ curl \ python3 \ py-pygments \ + imagemagick \ + ghostscript \ + msmtp \ composer \ php7 \ - php7-intl \ php7-fpm \ php7-cli \ + php7-intl \ php7-curl \ - php7-fileinfo \ - php7-mbstring \ - php7-gd \ php7-json \ php7-dom \ php7-pcntl \ php7-posix \ - php7-pgsql \ - php7-exif \ php7-mcrypt \ php7-session \ + php7-gd \ + php7-exif \ + php7-phar \ php7-pdo \ + php7-pgsql \ php7-pdo_pgsql \ - php7-ctype \ + php7-pdo_mysql \ php7-mysqli \ + php7-fileinfo \ + php7-mbstring \ + php7-ctype \ + php7-ldap \ php7-pecl-memcached \ memcached \ ca-certificates && \ @@ -100,6 +106,7 @@ RUN chmod -x /wait-for.sh && \ sed -i "s|;*upload_max_filesize =.*|upload_max_filesize = ${MAX_UPLOAD}|i" /etc/php7/php.ini && \ sed -i "s|;*max_file_uploads =.*|max_file_uploads = ${PHP_MAX_FILE_UPLOAD}|i" /etc/php7/php.ini && \ sed -i "s|;*post_max_size =.*|post_max_size = ${PHP_MAX_POST}|i" /etc/php7/php.ini && \ + sed -i 's+.*sendmail_path =.*+sendmail_path = "/usr/bin/msmtp -C /var/www/msmtprc --logfile /var/www/msmtp.log -a filebinmail -t"+' /etc/php7/php.ini && \ # clean up and permissions rm -rf /var/cache/apk/* && \ ln -s /usr/bin/python3 /usr/bin/python && \ @@ -113,8 +120,10 @@ EXPOSE 80 # add templates for replace env variables in the application ADD src/config/database.php.tpl /var/www/application/config/database.php.tpl ADD src/config/config-local.php.tpl /var/www/application/config/config-local.php.tpl -ADD src/configure.php /configure.php +ADD src/config/email.php.tpl /var/www/application/config/email.php.tpl ADD src/crontab /etc/periodic/15min/crontab +ADD src/configure.php /configure.php +ADD src/configure-mail.sh /var/www/configure-mail.sh # add overlay ADD src/s6/ /etc/s6/ diff --git a/src/config/config-local.php.tpl b/src/config/config-local.php.tpl index e14e39c..2e33728 100644 --- a/src/config/config-local.php.tpl +++ b/src/config/config-local.php.tpl @@ -40,14 +40,4 @@ $config['tarball_max_size'] = intval(%%%TARBALL_MAX_SIZE%%%); $config['tarball_cache_time'] = intval(%%%TARBALL_CACHE_TIME%%%); // The maximum number of active invitation keys per account. -$config['max_invitation_keys'] = intval(%%%MAX_INVITATION_KEYS%%%); - -// SMTP mail settings if enabled -if (getenv('SMTP_ENABLED') === 'true') { - $config['protocol'] = %%%SMTP_PROTOCOL%%%; - $config['smtp_host'] = %%%SMTP_HOST%%%; - $config['smtp_port'] = intval(%%%SMTP_PORT%%%); - $config['smtp_crypto'] = %%%SMTP_CRYPTO%%%; - $config['smtp_user'] = %%%SMTP_USER%%%; - $config['smtp_pass'] = %%%SMTP_PASS%%%; -} \ No newline at end of file +$config['max_invitation_keys'] = intval(%%%MAX_INVITATION_KEYS%%%); \ No newline at end of file diff --git a/src/config/email.php.tpl b/src/config/email.php.tpl new file mode 100644 index 0000000..120e6d7 --- /dev/null +++ b/src/config/email.php.tpl @@ -0,0 +1,13 @@ + %%%SMTP_PROTOCOL%%%, + 'smtp_host' => %%%SMTP_HOST%%%, + 'smtp_port' => intval(%%%SMTP_PORT%%%), + 'smtp_crypto' => %%%SMTP_CRYPTO%%%, + 'smtp_user' => %%%SMTP_USER%%%, + 'smtp_pass' => %%%SMTP_PASS%%%, + ]; +} \ No newline at end of file diff --git a/src/configure-mail.sh b/src/configure-mail.sh new file mode 100755 index 0000000..c9b0fe0 --- /dev/null +++ b/src/configure-mail.sh @@ -0,0 +1,20 @@ +#!/bin/sh + +function set_mail_config() { + +cat < /var/www/msmtprc +account filebinmail +tls on +tls_certcheck off +auth on +host ${SMTP_HOST} +port ${SMTP_PORT} +user ${SMTP_USER} +from ${EMAIL_FROM} +password ${SMTP_PASS} +EOF + + chmod 600 /var/www/msmtprc +} + +set_mail_config; \ No newline at end of file diff --git a/src/configure.php b/src/configure.php index fbf7e14..26e7f3f 100644 --- a/src/configure.php +++ b/src/configure.php @@ -2,33 +2,9 @@