Skip to content

Commit

Permalink
Switched to msmtp #61 #31
Browse files Browse the repository at this point in the history
  • Loading branch information
ckulka committed Jan 13, 2022
1 parent f6eaa24 commit c47f472
Show file tree
Hide file tree
Showing 13 changed files with 150 additions and 157 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ If you want to use local folders instead of Docker volumes, see [examples/docker

You can find more installation and configuration guides here:

- [Sendmail (email configuration)](https://github.com/ckulka/baikal-docker/blob/master/docs/ssl-certificates-guide.md)
- [Email Guide](https://github.com/ckulka/baikal-docker/blob/master/docs/email-guide.md)
- [SSL Certificate Guide](https://github.com/ckulka/baikal-docker/blob/master/docs/ssl-certificates-guide.md)
- [systemd Guide](https://github.com/ckulka/baikal-docker/blob/master/docs/systemd-guide.md)
- [Unraid Installation Guide](https://github.com/ckulka/baikal-docker/blob/master/docs/unraid-installation-guide.md)
Expand Down
10 changes: 5 additions & 5 deletions apache.dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@ LABEL website="http://sabre.io/baikal/"

# Install Baikal and required dependencies
COPY --from=builder baikal /var/www/baikal
RUN chown -R www-data:www-data /var/www/baikal &&\
apt-get update &&\
apt-get install -y libcurl4-openssl-dev sendmail &&\
rm -rf /var/lib/apt/lists/* &&\
RUN chown -R www-data:www-data /var/www/baikal &&\
apt-get update &&\
apt-get install -y libcurl4-openssl-dev msmtp msmtp-mta &&\
rm -rf /var/lib/apt/lists/* &&\
docker-php-ext-install curl pdo pdo_mysql

# Configure Apache + HTTPS
Expand All @@ -31,5 +31,5 @@ EXPOSE 443
VOLUME /var/www/baikal/config
VOLUME /var/www/baikal/Specific

COPY files/start.sh /opt
COPY files/start-*.sh /opt
CMD /opt/start-apache.sh
72 changes: 72 additions & 0 deletions docs/email-guide.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
# Email Guide

This guide outlines the email configuration so that you can send out email invitations. Many thanks to [@philippneugebauer](https://github.com/philippneugebauer), [@vaskozl](https://github.com/vaskozl), and everyone in [#61](https://github.com/ckulka/baikal-docker/discussions/61) for contributing.

In order to send out emails, you need a working SMTP service - you can host your own or rely on a service such as [Gmail](https://support.google.com/mail/answer/7126229?hl=en#zippy=%2Cstep-change-smtp-other-settings-in-your-email-client).

The entire email configuration is stored in the `MSMTPRC` environment variable.

## Generic SMTP server

If you have an SMTP server without security in place, i.e. no authentication or SSL/TLS/STARTTLS, then you only have to configure the SMTP server name. Needless to say it's highly recommended to have authentication and TLS in place.

```yaml
services:
baikal:
image: ckulka/baikal:nginx
environment:
MSMTPRC: |
defaults
account default
host <smtp host>
port 25
```
If you have TLS and authentication in place, add the following configuration parameters:
```yaml
services:
baikal:
image: ckulka/baikal:nginx
restart: always
environment:
MSMTPRC: |
defaults
auth on
tls on
tls_trust_file /etc/ssl/certs/ca-certificates.crt
account default
host <smtp host>
port 587
from [email protected]
user <user>
password <password>
```
See [examples/docker-compose.email.yaml](../examples/docker-compose.email.yaml) for a starter template.
## Gmail
If you use Gmail as your SMTP server, you have to first allow less secure apps (sendmail) to use Gmail, see [Less secure apps & your Google Account](https://support.google.com/accounts/answer/6010255?hl=en#zippy=).
Once that is done, use the following configuration:
```yaml
services:
baikal:
image: ckulka/baikal:nginx
environment:
MSMTPRC: |
defaults
auth on
tls on
tls_trust_file /etc/ssl/certs/ca-certificates.crt
account default
host smtp.gmail.com
port 587
from <user>@gmail.com
user <user>
password <password>
```
See [examples/docker-compose.sendmail-gmail.yaml](../examples/docker-compose.email-gmail.yaml) for a starter template.
68 changes: 0 additions & 68 deletions docs/sendmail-guide.md

This file was deleted.

29 changes: 29 additions & 0 deletions examples/docker-compose.email-gmail.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# Docker Compose file for a Baikal server
# See https://github.com/ckulka/baikal-docker/blob/master/docs/email-guide.md

version: "2"
services:
baikal:
image: ckulka/baikal:nginx
restart: always
environment:
MSMTPRC: |
defaults
auth on
tls on
tls_trust_file /etc/ssl/certs/ca-certificates.crt
account default
host smtp.gmail.com
port 587
from <user>@gmail.com
user <user>
password <password>
ports:
- "80:80"
volumes:
- config:/var/www/baikal/config
- data:/var/www/baikal/Specific

volumes:
config:
data:
29 changes: 29 additions & 0 deletions examples/docker-compose.email.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# Docker Compose file for a Baikal server
# See https://github.com/ckulka/baikal-docker/blob/master/docs/email-guide.md

version: "2"
services:
baikal:
image: ckulka/baikal:nginx
restart: always
environment:
MSMTPRC: |
defaults
auth on
tls on
tls_trust_file /etc/ssl/certs/ca-certificates.crt
account default
host <smtp host>
port 587
from [email protected]
user <user>
password <password>
ports:
- "80:80"
volumes:
- config:/var/www/baikal/config
- data:/var/www/baikal/Specific

volumes:
config:
data:
29 changes: 0 additions & 29 deletions examples/docker-compose.sendmail-gmail.yaml

This file was deleted.

21 changes: 0 additions & 21 deletions examples/docker-compose.sendmail.yaml

This file was deleted.

2 changes: 1 addition & 1 deletion files/start-apache.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/bin/sh

/opt/start-sendmail.sh
/opt/start-msmtp.sh

# Inject ServerName and ServerAlias if specified
APACHE_CONFIG="/etc/apache2/sites-available/000-default.conf"
Expand Down
11 changes: 11 additions & 0 deletions files/start-msmtp.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#!/bin/sh

# See https://github.com/ckulka/baikal-docker/discussions/61

# Insert sendmail mailer definitions
if [ ! -z ${MSMTPRC+x} ]
then
echo "$MSMTPRC" > /etc/msmtprc
chown root:msmtp /etc/msmtprc
chmod 640 /etc/msmtprc
fi
2 changes: 1 addition & 1 deletion files/start-nginx.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/bin/sh

/opt/start-sendmail.sh
/opt/start-msmtp.sh

/etc/init.d/php8.1-fpm start
chown -R nginx:nginx /var/www/baikal/Specific
Expand Down
30 changes: 0 additions & 30 deletions files/start-sendmail.sh

This file was deleted.

2 changes: 1 addition & 1 deletion nginx.dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ RUN curl -o /etc/apt/trusted.gpg.d/php.gpg https://packages.sury.org/php/apt.gpg
php8.1-sqlite3 \
php8.1-xml \
sqlite3 \
sendmail &&\
msmtp msmtp-mta &&\
rm -rf /var/lib/apt/lists/* &&\
sed -i 's/www-data/nginx/' /etc/php/8.1/fpm/pool.d/www.conf &&\
sed -i 's/^listen = .*/listen = \/var\/run\/php-fpm.sock/' /etc/php/8.1/fpm/pool.d/www.conf
Expand Down

0 comments on commit c47f472

Please sign in to comment.