A
A
Andrey Zhukov2019-12-13 20:56:13
PHP
Andrey Zhukov, 2019-12-13 20:56:13

How to set sendmail_path config for PHP-FPM in docker?

Puff is spinning in the docker.
Here is the Dockerfile:

FROM php:5.6.35-fpm

RUN apt-get update && apt-get install -y \
      curl \
      wget \
      git \
      nano \
      mc \
      htop \
      net-tools \
      iputils-ping \
      libfreetype6-dev \
      libjpeg62-turbo-dev \
      libmcrypt-dev \
      libpng12-dev \
      libpq-dev \
      libxml2-dev \
      g++ \
            libicu-dev \
            zlib1g-dev \
            libxslt-dev \
            zip \
        && pecl install xdebug-2.5.5 \
        && docker-php-ext-enable xdebug \
    && docker-php-ext-install -j$(nproc) iconv mcrypt mbstring mysqli pdo_mysql zip \
    && docker-php-ext-configure gd --with-freetype-dir=/usr/include/ --with-jpeg-dir=/usr/include/ \
    && docker-php-ext-install -j$(nproc) gd \
    && docker-php-ext-install -j$(nproc) pgsql \
    && docker-php-ext-install -j$(nproc) pdo_pgsql \
    && docker-php-ext-install -j$(nproc) soap \
    && docker-php-ext-install -j$(nproc) bcmath \
        && curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer

COPY docker-entrypoint.sh /usr/local/bin/
COPY mailtodisk /usr/local/bin

ADD php.ini /usr/local/etc/php/conf.d/40-custom.ini

WORKDIR /var/www

CMD ["/usr/local/bin/docker-entrypoint.sh"]

Here is my entrypoint script:
#!/bin/sh
groupmod -g $(stat -c '%g' /var/www) www-data
usermod -u $(stat -c '%u' /var/www) www-data
HOST_DOMAIN="host.docker.internal"
ping -q -c1 $HOST_DOMAIN > /dev/null 2>&1
if [ $? -ne 0 ]; then
  HOST_IP=$(ip route | awk 'NR==1 {print $3}')
  echo "$HOST_IP\t$HOST_DOMAIN" >> /etc/hosts
fi
php-fpm

And here, in fact, php.ini itself (which flies into the container):
php_admin_value[sendmail_path] = /usr/local/bin/mailtodisk
php_admin_value[error_log] = /var/log/fpm-php.www.log
php_admin_flag[log_errors] = on
xdebug.remote_enable=1
xdebug.remote_port=9000
xdebug.remote_autostart=1
xdebug.remote_connect_back=0
xdebug.idekey=PHPSTORM
xdebug.remote_host=host.docker.internal

Problem: sendmail_path is ignored, it does not reach the specified script. Nothing falls into the log, there are no assumptions.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Andrey Zhukov, 2019-12-17
@zhookovhz

Understood. Moved sendmail_path to a separate config, and at the very beginning added the pool name, something like this:
[www]
php_admin_value[sendmail_path] = /usr/local/bin/mailtodisk

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question