katefike / sage

A personal finance app that's like Mint, but better. It uses a dockerized postfix/dovecot email server. Parses transaction data from alert emails.
MIT License
5 stars 0 forks source link

Temporarily disable TLS and attempt to receive an email on the containerized production MX #114

Closed katefike closed 11 months ago

katefike commented 11 months ago

Configuration

See /docker/mailserver/config_copies/prod_copies_231218/

The droplet firewall: image

Tests

Send an email locally

Success!

kfike@pop-os:~$ telnet mail.example.com 25
Trying 178.128.132.77...
Connected to mail.example.com
Escape character is '^]'.
220 prod ESMTP Postfix (Ubuntu)
ehlo prod.sagefinancial.dev
250-prod
250-PIPELINING
250-SIZE 10240000
250-VRFY
250-ETRN
250-ENHANCEDSTATUSCODES
250-8BITMIME
250-DSN
250-SMTPUTF8
250 CHUNKING
MAIL FROM: <support@port25.com>
250 2.1.0 Ok
RCPT TO: <kfike@mail.example.com>
250 2.1.5 Ok
data
354 End data with <CR><LF>.<CR><LF>
Subject: Test email 1 yo
This is a test email. numero uno
.
250 2.0.0 Ok: queued as A8ADEC4820
quit
221 2.0.0 Bye
Connection closed by foreign host.

Send an email from gmail

Success!

source ~/sage/.venv/bin/activate
(.venv) kfike@prod:~/sage$ python3 scripts/get_all_emails.py
UID: 1
Date: 1900-01-01 00:00:00
To: ()
From: 
Text: This is a test email. numero uno

UID: 2
Date: 2023-12-18 07:06:02+07:00
To: ('kfike@mail.example.com',)
From: kate.e.fike@gmail.com
Text: This is a test email. numero dos.

2 emails were retrieved.
katefike commented 11 months ago

Troubleshooting: Send an unencrypted email locally

kfike@prod:~$ telnet localhost 25
Trying ::1...
Connected to localhost.
Escape character is '^]'.
220 prod ESMTP Postfix (Ubuntu)
ehlo mail.localdomain
250-prod
250-PIPELINING
250-SIZE 10240000
250-VRFY
250-ETRN
250-STARTTLS
250-ENHANCEDSTATUSCODES
250-8BITMIME
250-DSN
250-SMTPUTF8
250 CHUNKING
mail from: root@localhost
250 2.1.0 Ok
rcpt to: kfike@sagefinancial.dev
250 2.1.5 Ok
data
354 End data with <CR><LF>.<CR><LF>
Subject: Test email
This is a test email.
.
250 2.0.0 Ok: queued as 2AFC8C3067
quit
221 2.0.0 Bye
Connection closed by foreign host.

Docker says the email was delivered to Maildir:

sage-mailserver  | Nov 16 08:19:14 prod postfix/smtpd[258]: connect from unknown[172.21.0.1]
sage-mailserver  | Nov 16 08:20:26 prod postfix/smtpd[258]: 2AFC8C3067: client=unknown[172.21.0.1]
sage-mailserver  | Nov 16 08:20:46 prod postfix/cleanup[294]: 2AFC8C3067: message-id=<>
sage-mailserver  | Nov 16 08:20:46 prod postfix/qmgr[167]: 2AFC8C3067: from=<root@localhost>, size=218, nrcpt=1 (queue active)
sage-mailserver  | Nov 16 08:20:46 prod postfix/local[303]: 2AFC8C3067: to=<kfike@sagefinancial.dev>, relay=local, delay=42, delays=42/0.02/0/0.01, dsn=2.0.0, status=sent (delivered to maildir)

dovecot doesn't show any emails delivered though:

kfike@prod:~$ docker exec -it sage-mailserver bash
root@cd97a33c9b95:/# doveadm -f table mailbox status -u kfike all INBOX
mailbox messages recent uidnext uidvalidity unseen highestmodseq vsize guid                             firstsaved                                           
INBOX   0        0      1       1700122871  0      1             0     3e4d711ef7d05565410100002a97ba1c 18446744073709551615

But lsing Maildir shows the message is there :D :

root@cd97a33c9b95:~# cat /home/kfike/Maildir/new/1700122846.V2dIc306bM596332.cd97a33c9b95
Return-Path: <root@localhost>
X-Original-To: kfike@sagefinancial.dev
Delivered-To: kfike@sagefinancial.dev
Received: from mail.localdomain (unknown [172.21.0.1])
    by prod (Postfix) with ESMTP id 2AFC8C3067
    for <kfike@sagefinancial.dev>; Thu, 16 Nov 2023 08:20:04 +0000 (UTC)
Subject: Test email

This is a test email.

Success locally sending an email