Skip to content
This repository has been archived by the owner on Dec 14, 2023. It is now read-only.

Update postfix headers #771

Merged
merged 12 commits into from
Mar 5, 2021
3 changes: 3 additions & 0 deletions apps/common/src/python/mediawords/util/mail.py
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,9 @@ def send_email(message: Message) -> bool:
message_part = MIMEText(message.text_body, 'plain', 'utf-8')
mime_message.attach(message_part)

mime_message.add_header('List-Unsubscribe',
'mailto:[email protected]?subject=Delete%20account%20and%20unsubscribe')

# HTML gets attached last, thus making it a preferred part as per RFC
if message.html_body:
message_part = MIMEText(message.html_body, 'html', 'utf-8')
Expand Down
5 changes: 4 additions & 1 deletion apps/mail-postfix-server/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -50,13 +50,16 @@ RUN \
#
# Filter out "Received:" and some other headers
postconf -e header_checks=regexp:/etc/postfix/header_checks && \
postconf -e mime_header_checks=regexp:/etc/postfix/header_checks && \
postconf -e smtp_header_checks=regexp:/etc/postfix/header_checks && \
#
# Don't require TLS as local clients are trusted
postconf -e smtp_tls_security_level=may && \
postconf -e smtpd_tls_security_level=none && \
#
# Make sure default headers (e.g. Message-Id, date) are present
postconf -e always_add_missing_headers=yes && \
postconf -e local_header_rewrite_clients=permit_inet_interfaces && \
#
# Disable chroot on all services as it doesn't play well with a mounted
# volume, e.g. "smtpd" is unable to access libnss after a chroot and thus
# resolve OpenDKIM container.
Expand Down
17 changes: 14 additions & 3 deletions apps/mail-postfix-server/docker-compose.tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,24 @@ services:
#
# Usage:
#
# host$ ./dev/run.py mail-postfix-server bash
# container$ sendmail "[email protected]"
# - host$ ./dev/run.py mail-postfix-server bash
# - (new terminal window) host$ docker ps
# - find container with name ending in 'mail-postfix-server-actual_1'
# - host$ docker exec -it some_string_mail-postfix-server-actual_1 bash
# - mail-postfix-server-actual_1_container$ ./postfix.sh
# - open new terminal window on your host machine
# - host$ docker exec -it some_string_mail-postfix-server-actual_1 bash
# - follow instructions at URL below to create a test mail.txt file and send to your email address from the container
# https://clients.javapipe.com/knowledgebase/132/How-to-Test-Sendmail-From-Command-Line-on-Linux.html
#
mail-postfix-server:
image: gcr.io/mcback/common:latest
init: true
stop_signal: SIGKILL
volumes:
- type: bind
source: ./../common/src/
target: /opt/mediacloud/src/common/
depends_on:
- mail-postfix-server-actual

Expand All @@ -21,7 +32,7 @@ services:
image: gcr.io/mcback/mail-postfix-server:latest
init: true
stop_signal: SIGKILL
# "docker exec" into a container and run Postfix manually (/postfix.sh):
# "docker exec" into a container and run Postfix manually (./postfix.sh):
command: sleep infinity
# To be able to set /proc/sys/kernel/yama/ptrace_scope:
privileged: true
Expand Down
1 change: 0 additions & 1 deletion apps/mail-postfix-server/header_checks
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
/^Received:.*with ESMTP / IGNORE
/^X-Originating-IP:/ IGNORE
/^X-Mailer:/ IGNORE
/^Mime-Version:/ IGNORE
/^User-Agent:/ IGNORE
5 changes: 4 additions & 1 deletion apps/topics-map/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,10 @@
FROM gcr.io/mcback/common:latest

# Install Java
RUN apt-get -y --no-install-recommends install openjdk-8-jre-headless
RUN \
apt-get update && \
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you add a quick -y flag here, as in apt-get -y update? The update sub-command typically doesn't ask for questions but it might (I suppose), or (maybe) I have even seen it asking me for something, so it wouldn't hurt to have a -y here just like everywhere else.

apt-get -y --no-install-recommends install openjdk-8-jre-headless && \
true

# Install fa2l Java libs
RUN \
Expand Down