Thank you @asmecher ! This looks like something for the developers rather then simple wannabe administrators - I looked at the docs but I don’t even know where to put the .env file for Laravel. However, your link was quite useful otherwise, as it mentions other methods of testing SMTP. I tried mailpit and it works, but if I don’t document the process I’ll forget everything in half an hour, so I’m just leaving this here. Maybe this will be useful for someone who wants to test the mailing functions in a simple way. I searched mailpit but haven’t found anything on this forum.
What:
mailpit https://mailpit.axllent.org/ is a “fake” SMTP server with a web UI that allows you to see the messages that are sent via it (by the OJS in this case) without actually sending the messages to the real recipients (although forwarding/relaying are also available). It can run on several OSes as well as in docker.
Tech stack in this example:
OJS 3.3.0.21 running in LAMP on the host Debian machine (not in docker). We are installing mailpit in a docker container and proxying its web interface through apache.
Steps:
-
Ensure that you have docker and docker compose or install them by following the official guide Debian | Docker Docs .
-
Make a folder for the mailpit project and switch to it
mkdir mailpit && cd mailpit
- Create the self-signed SSL certificates for the localhost to enable the SMTP TLS authentication basically as described here https://mailpit.axllent.org/docs/configuration/certificates/
mkdir ssl && openssl req -x509 -newkey rsa:4096 -nodes -keyout ./ssl/key.pem -out ./ssl/cert.pem -sha256 -days 3650 -addext "subjectAltName = DNS:localhost"
- Create the docker-compose file, which is a modified version of the official recommendation https://mailpit.axllent.org/docs/install/docker/#docker-compose-example . You will also need to change the
MP_WEBROOT parameter (if its value is pit, the web interface will be accessible via example.com/pit) and the MP_UI_AUTH parameter (it defines the username:password for the HTTP basic auth so as to make the web interface accessible only for you).
cat > docker-compose.yaml <<EOF
services:
mailpit:
image: axllent/mailpit
container_name: mailpit
restart: unless-stopped
volumes:
- ./data:/data
- ./ssl:/ssl
ports:
- 127.0.0.1:8025:8025
- 127.0.0.1:1025:1025
environment:
MP_MAX_MESSAGES: 5000
MP_DATABASE: /data/mailpit.db
MP_SMTP_AUTH_ACCEPT_ANY: 1
MP_SMTP_REQUIRE_STARTTLS: 1
MP_SMTP_TLS_CERT: /ssl/cert.pem
MP_SMTP_TLS_KEY: /ssl/key.pem
MP_WEBROOT: pit
MP_UI_AUTH: "mail:pass"
EOF
- The system is kinda secured already because we have basic auth enabled and the ports for the SMTP and the web interface are exposed to the localhost only. So we can now run the container:
sudo docker compose up -d
- Time to configure the apache proxy. Ensure that the proxy mods are enabled:
sudo a2enmod proxy proxy_http proxy_wstunnel
and then add this to the vhost for example.com (where example.com is, e.g., the FQDN of your journal) - the vhost that listens on port 443, the secure one! This is important as we’re using HTTP basic auth.
<Location "/pit">
ProxyPreserveHost on
ProxyPass "http://127.0.0.1:8025/pit" upgrade=websocket
ProxyPassReverse "http://127.0.0.1:8025/pit"
Require all granted
</Location>
This also differs from the official proxy recommendations https://mailpit.axllent.org/docs/configuration/proxy/ because it is written for proxying the docker container and for the newer apache versions that support the simplified “upgrade=websocket” declaration.
- Test the configuration and reload the apache settings
sudo apachectl configtest && sudo systemctl reload apache2.service
- Now (if I didn’t forget anything) the web interface should be accessible via https://example.com/pit and it is time to alter
config.inc.php to configure the OJS to send the messages via mailpit. The most important settings are:
smtp = On
smtp_server = localhost
smtp_port = 1025
smtp_auth = tls
smtp_username = journal@example.com
smtp_password = qwerty
smtp_suppress_cert_check = On
so that we will connect via SMTP to the port 1025 exposed to the localhost with the tls auth. We have MP_SMTP_AUTH_ACCEPT_ANY set to 1 (see the docker-compose file above) so our mailpit will accept any username/password credentials. I guess you can even leave your real ones if you’re temporarily switching from the actual SMTP server to mailpit. smtp_suppress_cert_check is On because of self-signed certificate that we created for mailpit.
And now you can send the emails from your OJS and check them in the mailpit’s web interface. Neat!