Accessing IMAP from Python with Encrypted Password
Hello again Dovecoters! I have a need to access an IMAP mailbox via a Python script to parse and stored DMARC reports in a SQL database. Right now, I have it working however I am storing the password in plaintext in my database which obviously is not secure. How would you approach this scenario? Would you store the password in the database encrypted and configure Dovecot to accept said encrypted password? If so, can you point me in the right direction to configure Dovecot to handle this? If not, what would you recommend? Is it possible to intercept the email and upload the attachments to an AWS S3 bucket then move the email to another folder? Likewise, if someone wants to help here as well, I need to send outbound email via an authenticated user from Postfix. How would you approach this scenario? Thank you!
On 09/06/2024 07:39 EEST adam--- via dovecot dovecot@dovecot.org wrote:
Hello again Dovecoters! I have a need to access an IMAP mailbox via a Python script to parse and stored DMARC reports in a SQL database. Right now, I have it working however I am storing the password in plaintext in my database which obviously is not secure. How would you approach this scenario? Would you store the password in the database encrypted and configure Dovecot to accept said encrypted password? If so, can you point me in the right direction to configure Dovecot to handle this?
The client must have the password in some usable form, which usually is plaintext. The only practical alternatives are GSSAPI or Certificate authentication.
If you are running the tool on *same* server, you can also directly access the mailbox with doveadm exec imap -u username
, if you want to do some subprocess based solution.
If not, what would you recommend? Is it possible to
intercept the email and upload the attachments to an AWS S3 bucket then move the email to another folder?
Pratical S3 interactions require Dovecot Pro version.
Likewise, if someone wants to help here as well, I need to send outbound email via an authenticated user from Postfix. How would you approach this scenario?
One option is to use dovecot submission service, and configure that to relay your mail, after authentication, to your MX servers. See https://doc.dovecot.org/admin_manual/submission_server/
Thank you!
Regards,
Aki
participants (3)
-
adam@ardaemail.com
-
Aki Tuomi
-
Ralph Seichter