tiredofit / docker-db-backup

Backup multiple database types on a scheduled basis with many customizable options
MIT License
882 stars 127 forks source link

SMTP authentication #353

Open manshurtigh opened 4 months ago

manshurtigh commented 4 months ago

Summary

Email is not sent. Need to specify SMTP authentication.

Steps to reproduce

Configure below:

      - ENABLE_NOTIFICATIONS=TRUE
      - NOTIFICATION_TYPE=EMAIL
      - MAIL_FROM=mail@example.se
      - MAIL_TO=mail@example.se
      - SMTP_HOST=smtp.example.se
      - SMTP_PORT=465

What is the expected correct behavior?

All smtp servers expect an authentication.

Environment

Possible fixes

I don't know if it's not documented or I cannot find it?

effectivelywild commented 3 months ago

To get around this I added a postfix relay that supports authentication and referenced that in my db-backup configuration.


  postfixrelay:
    container_name: postfixrelay
    image: loganmarchione/docker-postfixrelay:latest
    restart: unless-stopped
    environment:
      - TZ=America/Los_Angeles
      - RELAY_HOST=email-smtp.us-east-1.amazonaws.com
      - RELAY_PORT=587
      - RELAY_USER=<USER>
      - RELAY_PASS=<PASS>
    networks:
      - docker-backup
    ports:
      - 25:25
    volumes:
      - postfixrelay_data:/var/spool/postfix
alwynpan commented 3 months ago

I suppose you can mount a msmtp configuration file to /etc/msmtprc.

manshurtigh commented 3 months ago

To get around this I added a postfix relay that supports authentication and referenced that in my db-backup configuration.

  postfixrelay:
    container_name: postfixrelay
    image: loganmarchione/docker-postfixrelay:latest
    restart: unless-stopped
    environment:
      - TZ=America/Los_Angeles
      - RELAY_HOST=email-smtp.us-east-1.amazonaws.com
      - RELAY_PORT=587
      - RELAY_USER=<USER>
      - RELAY_PASS=<PASS>
    networks:
      - docker-backup
    ports:
      - 25:25
    volumes:
      - postfixrelay_data:/var/spool/postfix

This seems like a great idea. Could you also provide how you specify the postfixrelay container in the configuration for the docker-db-backup?

effectivelywild commented 3 months ago

I included the following environment variables:

      NOTIFICATION_TYPE: EMAIL
      MAIL_FROM: backup@example.local
      MAIL_TO: admin@example.local
      SMTP_HOST: postfixrelay
      SMTP_PORT: 25

postfixrelay being the name of my postfix container.

manshurtigh commented 3 months ago

Cheers! I got the postfixrelay container working. Successfully sent a test email. However, if I run a "backup-now" in the docker-db-backup container it does not send an email. I don't even see it trying in the logs of the postfixrelay container.

Below is configured in docker-db-backup

ENABLE_NOTIFICATIONS=true
NOTIFICATION_TYPE=EMAIL

I even get a notice in the log saying:

2024-08-14.21:02:16 [NOTICE] ** [messaging] Container configured to route mail via SMTP to 'postfixrelay