Migrated away from PHP Mail Parser to the new WebKlex PHP IMAP Mail Parser this will open the way to support OAUTH2 for Mail servers such as Microsoft 365 and Google Workspaces

This commit is contained in:
johnnyq
2024-06-12 15:39:52 -04:00
parent d64a7ce31e
commit 779527cf6a
218 changed files with 14781 additions and 2722 deletions

View File

@@ -0,0 +1,23 @@
FROM ubuntu:latest
LABEL maintainer="Webklex <github@webklex.com>"
RUN apt-get update
RUN apt-get upgrade -y
RUN apt-get install -y sudo dovecot-imapd
ENV LIVE_MAILBOX=true
ENV LIVE_MAILBOX_HOST=mail.example.local
ENV LIVE_MAILBOX_PORT=993
ENV LIVE_MAILBOX_ENCRYPTION=ssl
ENV LIVE_MAILBOX_VALIDATE_CERT=true
ENV LIVE_MAILBOX_USERNAME=root@example.local
ENV LIVE_MAILBOX_PASSWORD=foobar
ENV LIVE_MAILBOX_QUOTA_SUPPORT=true
EXPOSE 993
ADD dovecot_setup.sh /root/dovecot_setup.sh
RUN chmod +x /root/dovecot_setup.sh
CMD ["/bin/bash", "-c", "/root/dovecot_setup.sh && tail -f /dev/null"]

View File

@@ -0,0 +1,63 @@
#!/bin/sh
set -ex
sudo apt-get -q update
sudo apt-get -q -y install dovecot-imapd
{
echo "127.0.0.1 $LIVE_MAILBOX_HOST"
} | sudo tee -a /etc/hosts
SSL_CERT="/etc/ssl/certs/dovecot.crt"
SSL_KEY="/etc/ssl/private/dovecot.key"
sudo openssl req -new -x509 -days 3 -nodes \
-out "$SSL_CERT" \
-keyout "$SSL_KEY" \
-subj "/C=EU/ST=Europe/L=Home/O=Webklex/OU=Webklex DEV/CN=""$LIVE_MAILBOX_HOST"
sudo chown root:dovecot "$SSL_CERT" "$SSL_KEY"
sudo chmod 0440 "$SSL_CERT"
sudo chmod 0400 "$SSL_KEY"
DOVECOT_CONF="/etc/dovecot/local.conf"
MAIL_CONF="/etc/dovecot/conf.d/10-mail.conf"
IMAP_CONF="/etc/dovecot/conf.d/20-imap.conf"
QUOTA_CONF="/etc/dovecot/conf.d/90-quota.conf"
sudo touch "$DOVECOT_CONF" "$MAIL_CONF" "$IMAP_CONF" "$QUOTA_CONF"
sudo chown root:dovecot "$DOVECOT_CONF" "$MAIL_CONF" "$IMAP_CONF" "$QUOTA_CONF"
sudo chmod 0640 "$DOVECOT_CONF" "$MAIL_CONF" "$IMAP_CONF" "$QUOTA_CONF"
{
echo "ssl = required"
echo "disable_plaintext_auth = yes"
echo "ssl_cert = <""$SSL_CERT"
echo "ssl_key = <""$SSL_KEY"
echo "ssl_protocols = !SSLv2 !SSLv3"
echo "ssl_cipher_list = AES128+EECDH:AES128+EDH"
} | sudo tee -a "$DOVECOT_CONF"
{
echo "mail_plugins = \$mail_plugins quota"
} | sudo tee -a "$MAIL_CONF"
{
echo "protocol imap {"
echo " mail_plugins = \$mail_plugins imap_quota"
echo "}"
} | sudo tee -a "$IMAP_CONF"
{
echo "plugin {"
echo " quota = maildir:User quota"
echo " quota_rule = *:storage=1G"
echo "}"
} | sudo tee -a "$QUOTA_CONF"
sudo useradd --create-home --shell /bin/false "$LIVE_MAILBOX_USERNAME"
echo "$LIVE_MAILBOX_USERNAME"":""$LIVE_MAILBOX_PASSWORD" | sudo chpasswd
sudo service dovecot restart
sudo doveadm auth test -x service=imap "$LIVE_MAILBOX_USERNAME" "$LIVE_MAILBOX_PASSWORD"