Dear docker forum,
I’m relatively new to docker so maybe I’m doing something stupid but what I’m trying to do is the following.
I have written some PHP code to send some emails from within my own written system.
The code works perfectly when running on my local webserver (apache2, php and mysql-server) but as soon as I put it in docker with the following Dockerfile it won’t send any email.
FROM ubuntu:18.04
LABEL Maintainer="Jesse Mulder"
EXPOSE 80/tcp
# Base setup
RUN apt-get update && apt-get upgrade -y
# Locales setup
RUN apt-get install locales locales-all -y && locale-gen en_US.UTF-8
ENV LANG en_US.UTF-8
ENV LANGUAGE en_US:en
ENV LC_ALL en_US.UTF-8
RUN apt-get update && \
export DEBIAN_FRONTEND=noninteractive && \
apt-get install apache2 libapache2-mod-php php-mysql mysql-client libssl-dev -y
#Website toevoegen
### Add the website
ADD --chown=root:www-data sources/html /var/www/html
RUN chown -R root:www-data /var/www/html/
RUN chmod -R 774 /var/www/html/*
RUN apt-get autoclean -y && \
apt-get autoremove -y && \
rm -rf /tmp/*
RUN echo "extension=openssl" >> /etc/php/7.2/apache2/php.ini
WORKDIR /root
ADD --chown=root:root entrypoint.sh /opt/run/entrypoint.sh
RUN chmod 700 /opt/run/entrypoint.sh
ENTRYPOINT /opt/run/entrypoint.sh
The entrypoint.sh contains only a tail -f on the apache2 access log file. So the container stays running.
I’m using phpmailer to handle the emails for me, but when running in this docker it gives me the following error. (using gmail as smtp server)
2019-05-03 06:55:23 SERVER -> CLIENT: 220 smtp.gmail.com ESMTP o47sm370336edc.37 - gsmtp
2019-05-03 06:55:23 CLIENT -> SERVER: EHLO pvb-mail
2019-05-03 06:55:23 SERVER -> CLIENT: 250-smtp.gmail.com at your service, [xxx.xxx.xxx.xxx]
250-SIZE 35882577
250-8BITMIME
250-STARTTLS
250-ENHANCEDSTATUSCODES
250-PIPELINING
250-CHUNKING
250 SMTPUTF8
2019-05-03 06:55:23 CLIENT -> SERVER: STARTTLS
2019-05-03 06:55:23 SERVER -> CLIENT: 220 2.0.0 Ready to start TLS
SMTP Error: Could not connect to SMTP host.
2019-05-03 06:55:23 CLIENT -> SERVER: QUIT
2019-05-03 06:55:23
2019-05-03 06:55:23
SMTP connect() failed. https://github.com/PHPMailer/PHPMailer/wiki/Troubleshooting
Does anyone know a solution to this?
Thanks in advance!
Kind regards,
Jesse Mulder
Edits
- Added libssl-dev package
- Added extension=openssl to php.ini for apache2