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

Fix IMAP MailBox login with TLS #113

Closed katefike closed 8 months ago

katefike commented 11 months ago

Problem

When you run the script to get all emails on production, there's an error related to TLS:

kfike@pop-os:~$ ssh kfike@123.456.789.12 -i ~/.ssh/sage_prod
kfike@prod:~$ sudo su
root@prod:/home/kfike# cd sage
root@prod:/home/kfike/sage# source .venv/bin/activate
(.venv) root@prod:/home/kfike/sage# python3 scripts/get_all_emails.py
FAILED
MAILSERVER ERROR: Failed to connect via IMAP to the inbox of user kfike: Response status "OK" expected, but "NO" received. Data: [b'[PRIVACYREQUIRED] Plaintext authentication disallowed on non-secure (SSL/TLS) connections.']

Solutions

Either disable TLS for local IMAP

# Configures /etc/dovecot/dovecot.conf for production
# Clear the file contents
:> /etc/dovecot/dovecot.conf
cat >> /etc/dovecot/dovecot.conf <<EOF
protocols = "imap"
disable_plaintext_auth = no
mail_privileged_group = mail
mail_location = maildir:~/Maildir
userdb {
  driver = passwd
}
passdb {
  driver = shadow
}

service auth {
  unix_listener /var/spool/postfix/private/auth {
    group = postfix
    mode = 0660
    user = postfix
  }
}
EOF

Or use encrypted IMAP.

I decided to disable encrypted IMPA because IMAP is only accessed internally on the host.