entrypoint.sh 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637
  1. #!/usr/bin/env bash
  2. set -euo pipefail
  3. MAIL_HOSTNAME="${MAIL_HOSTNAME:-mailhub.local}"
  4. MAIL_ORIGIN_DOMAIN="${MAIL_ORIGIN_DOMAIN:-${MAIL_HOSTNAME#*.}}"
  5. POSTFIX_LOG_FILE="${POSTFIX_LOG_FILE:-/dev/stdout}"
  6. POSTFIX_PROXY_INTERFACES="${POSTFIX_PROXY_INTERFACES:-${SENDING_IP:-}}"
  7. if [[ "${POSTFIX_LOG_FILE}" != "/dev/stdout" ]]; then
  8. mkdir -p "$(dirname "${POSTFIX_LOG_FILE}")"
  9. touch "${POSTFIX_LOG_FILE}"
  10. chmod 666 "${POSTFIX_LOG_FILE}"
  11. tail -n 0 -F "${POSTFIX_LOG_FILE}" &
  12. fi
  13. postconf -e "myhostname = ${MAIL_HOSTNAME}"
  14. postconf -e "myorigin = ${MAIL_ORIGIN_DOMAIN}"
  15. postconf -e "mydestination ="
  16. postconf -e "inet_interfaces = all"
  17. postconf -e "inet_protocols = ipv4"
  18. if [[ -n "${POSTFIX_PROXY_INTERFACES}" ]]; then
  19. postconf -e "proxy_interfaces = ${POSTFIX_PROXY_INTERFACES}"
  20. fi
  21. postconf -e "mynetworks = 127.0.0.0/8 10.0.0.0/8 172.16.0.0/12 192.168.0.0/16"
  22. postconf -e "smtpd_relay_restrictions = permit_mynetworks, reject_unauth_destination"
  23. postconf -e "smtp_tls_security_level = may"
  24. postconf -e "smtp_tls_loglevel = 1"
  25. postconf -e "smtp_tls_CAfile = /etc/ssl/certs/ca-certificates.crt"
  26. postconf -e "smtp_helo_name = ${MAIL_HOSTNAME}"
  27. postconf -e "best_mx_transport = smtp:[app]:25"
  28. postconf -e "disable_vrfy_command = yes"
  29. postconf -e "maximal_queue_lifetime = 2d"
  30. postconf -e "bounce_queue_lifetime = 2d"
  31. postconf -e "maillog_file = ${POSTFIX_LOG_FILE}"
  32. newaliases || true
  33. exec postfix start-fg