From fbabdff69c7df2a0052d1ecd577f340ba80d937c Mon Sep 17 00:00:00 2001 From: galaxyoyo Date: Sun, 8 Sep 2019 23:10:59 +0200 Subject: [PATCH] Configuration du Dockerfile et support de l'envoi de mails --- Dockerfile | 31 +++++++++++++++++++++++++- server_files/services/mail.php | 4 ++-- setup.sql => setup/create_database.sql | 4 ++-- setup/msmtprc | 18 +++++++++++++++ 4 files changed, 52 insertions(+), 5 deletions(-) rename setup.sql => setup/create_database.sql (98%) create mode 100644 setup/msmtprc diff --git a/Dockerfile b/Dockerfile index 04f51b8..e6e897f 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,8 +1,37 @@ FROM php:7.3-apache as plateforme-builder +# Enabling apache rewrite mod RUN a2enmod rewrite +RUN apt clean && apt update && apt upgrade -y + +# Install MySQL drivers RUN docker-php-ext-install pdo_mysql \ && docker-php-ext-enable pdo_mysql -COPY . /var/www/html/ +# Install zip utilities +RUN apt install -y libzip-dev zip \ + && docker-php-ext-configure zip --with-libzip \ + && docker-php-ext-install zip \ + && docker-php-ext-enable zip + +# Setup locales +RUN apt install locales locales-all -y && locale-gen fr_FR.UTF-8 +ENV LANG fr_FR.UTF-8 +ENV LANGUAGE fr_FR:fr +ENV LC_ALL fr_FR.UTF-8 + +# Setup timezone +RUN echo Europe/Paris > /etc/timezone \ + && ln -sf /usr/share/zoneinfo/Europe/Paris /etc/localtime \ + && dpkg-reconfigure -f noninteractive tzdata + +# Setup mailing +RUN apt install -yq msmtp ca-certificates +COPY setup/msmtprc /etc/msmtprc +RUN echo "sendmail_path=msmtp -t" >> /usr/local/etc/php/conf.d/php-sendmail.ini + +# Setting environment +ENV TFJM_LOCAL_PATH /var/www/html +ENV TFJM_MAIL_DOMAIN tfjm.org +ENV TFJM_URL_BASE https://inscription.tfjm.org diff --git a/server_files/services/mail.php b/server_files/services/mail.php index 51b2adb..7f6d871 100644 --- a/server_files/services/mail.php +++ b/server_files/services/mail.php @@ -9,8 +9,8 @@ class Mailer $content = preg_replace("#{URL_BASE}#", $URL_BASE, $content); $content = preg_replace("#{YEAR}#", $YEAR, $content); - $headers = "From: " . $from . "@" . $MAIL_DOMAIN . "\r\n"; - $headers .= "Reply-To: contact@" . $MAIL_DOMAIN . "\r\n"; + $headers = "From: \"Contact TFJM²\" <" . $from . "@" . $MAIL_DOMAIN . ">\r\n"; + $headers .= "Reply-To: \"Contact TFJM²\" \r\n"; $headers .= "Content-Type: text/html; charset=UTF-8\r\n"; mail($email, $subject, $content, $headers); diff --git a/setup.sql b/setup/create_database.sql similarity index 98% rename from setup.sql rename to setup/create_database.sql index 471a5d9..d885d4f 100644 --- a/setup.sql +++ b/setup/create_database.sql @@ -19,8 +19,8 @@ SET time_zone = "+02:00"; -- -- Base de données : `tfjm` -- -CREATE DATABASE IF NOT EXISTS `tfjm` DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci; -USE `tfjm`; +CREATE DATABASE IF NOT EXISTS `inscription-tfjm` DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci; +USE `inscription-tfjm`; -- -------------------------------------------------------- diff --git a/setup/msmtprc b/setup/msmtprc new file mode 100644 index 0000000..3a3cc60 --- /dev/null +++ b/setup/msmtprc @@ -0,0 +1,18 @@ +defaults +auth on +tls on +tls_starttls off +tls_trust_file /etc/ssl/certs/ca-certificates.crt +syslog on +logfile /var/log/msmtp.log + +account tfjm +host ssl0.ovh.net +auth on +port 465 +from contact@tfjm.org +user contact@tfjm.org +passwordeval "echo $TFJM_MAIL_PASSWORD" + +# Set a default account +account default : tfjm