mirror of
https://github.com/mailcow/mailcow-dockerized.git
synced 2026-06-17 03:50:30 +00:00
Compare commits
4 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 0ae8e02ac0 | |||
| 6633da54d4 | |||
| c7d020f9ff | |||
| c4135f7033 |
@@ -246,25 +246,6 @@ while true; do
|
|||||||
done
|
done
|
||||||
VALIDATED_CONFIG_DOMAINS+=("${VALIDATED_CONFIG_DOMAINS_SUBDOMAINS[*]}")
|
VALIDATED_CONFIG_DOMAINS+=("${VALIDATED_CONFIG_DOMAINS_SUBDOMAINS[*]}")
|
||||||
done
|
done
|
||||||
|
|
||||||
# Fetch alias domains where target domain has MTA-STS enabled
|
|
||||||
if [[ ${AUTODISCOVER_SAN} == "y" ]]; then
|
|
||||||
SQL_ALIAS_DOMAINS=$(mariadb --skip-ssl --socket=/var/run/mysqld/mysqld.sock -u ${DBUSER} -p${DBPASS} ${DBNAME} -e "SELECT ad.alias_domain FROM alias_domain ad INNER JOIN mta_sts m ON ad.target_domain = m.domain WHERE ad.active = 1 AND m.active = 1" -Bs)
|
|
||||||
if [[ $? -eq 0 ]]; then
|
|
||||||
while read alias_domain; do
|
|
||||||
if [[ -z "${alias_domain}" ]]; then
|
|
||||||
# ignore empty lines
|
|
||||||
continue
|
|
||||||
fi
|
|
||||||
# Only add mta-sts subdomain for alias domains
|
|
||||||
if [[ "mta-sts.${alias_domain}" != "${MAILCOW_HOSTNAME}" ]]; then
|
|
||||||
if check_domain "mta-sts.${alias_domain}"; then
|
|
||||||
VALIDATED_CONFIG_DOMAINS+=("mta-sts.${alias_domain}")
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
done <<< "${SQL_ALIAS_DOMAINS}"
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if check_domain ${MAILCOW_HOSTNAME}; then
|
if check_domain ${MAILCOW_HOSTNAME}; then
|
||||||
|
|||||||
@@ -121,7 +121,13 @@ echo -n 'quota acl zlib mail_crypt mail_crypt_acl mail_log notify fts fts_flatcu
|
|||||||
echo -n 'quota imap_quota imap_acl acl zlib imap_zlib imap_sieve mail_crypt mail_crypt_acl notify mail_log fts fts_flatcurve listescape replication' > /etc/dovecot/mail_plugins_imap
|
echo -n 'quota imap_quota imap_acl acl zlib imap_zlib imap_sieve mail_crypt mail_crypt_acl notify mail_log fts fts_flatcurve listescape replication' > /etc/dovecot/mail_plugins_imap
|
||||||
echo -n 'quota sieve acl zlib mail_crypt mail_crypt_acl fts fts_flatcurve notify listescape replication' > /etc/dovecot/mail_plugins_lmtp
|
echo -n 'quota sieve acl zlib mail_crypt mail_crypt_acl fts fts_flatcurve notify listescape replication' > /etc/dovecot/mail_plugins_lmtp
|
||||||
fi
|
fi
|
||||||
chmod 644 /etc/dovecot/mail_plugins /etc/dovecot/mail_plugins_imap /etc/dovecot/mail_plugins_lmtp /templates/quarantine.tpl
|
|
||||||
|
# Create empty extra plugin files if they don't exist (can be populated via extra.conf or direct file)
|
||||||
|
for plugin_file in mail_plugins_extra mail_plugins_imap_extra mail_plugins_lmtp_extra; do
|
||||||
|
[[ ! -f /etc/dovecot/${plugin_file} ]] && touch /etc/dovecot/${plugin_file}
|
||||||
|
done
|
||||||
|
|
||||||
|
chmod 644 /etc/dovecot/mail_plugins /etc/dovecot/mail_plugins_imap /etc/dovecot/mail_plugins_lmtp /etc/dovecot/mail_plugins_extra /etc/dovecot/mail_plugins_imap_extra /etc/dovecot/mail_plugins_lmtp_extra /templates/quarantine.tpl
|
||||||
|
|
||||||
cat <<EOF > /etc/dovecot/sql/dovecot-dict-sql-userdb.conf
|
cat <<EOF > /etc/dovecot/sql/dovecot-dict-sql-userdb.conf
|
||||||
# Autogenerated by mailcow
|
# Autogenerated by mailcow
|
||||||
|
|||||||
@@ -1,6 +1,25 @@
|
|||||||
# --------------------------------------------------------------------------
|
# --------------------------------------------------------------------------
|
||||||
# Please create a file "extra.conf" for persistent overrides to dovecot.conf
|
# Please create a file "extra.conf" for persistent overrides to dovecot.conf
|
||||||
# --------------------------------------------------------------------------
|
# --------------------------------------------------------------------------
|
||||||
|
# To extend mail_plugins, you have two options:
|
||||||
|
#
|
||||||
|
# Option 1 (Recommended): Use the extra plugin files directly
|
||||||
|
# Create/edit data/conf/dovecot/mail_plugins_extra (for global plugins)
|
||||||
|
# Create/edit data/conf/dovecot/mail_plugins_imap_extra (for IMAP-specific plugins)
|
||||||
|
# Create/edit data/conf/dovecot/mail_plugins_lmtp_extra (for LMTP-specific plugins)
|
||||||
|
# Note: These paths are on the host. Inside the container they are /etc/dovecot/mail_plugins_*
|
||||||
|
# Example to add the virtual plugin for IMAP:
|
||||||
|
# echo -n ' virtual' > data/conf/dovecot/mail_plugins_imap_extra
|
||||||
|
# docker-compose restart dovecot-mailcow
|
||||||
|
#
|
||||||
|
# Option 2: Override protocol sections in extra.conf
|
||||||
|
# Create data/conf/dovecot/extra.conf with protocol-specific overrides:
|
||||||
|
# protocol imap {
|
||||||
|
# mail_plugins = $mail_plugins virtual
|
||||||
|
# }
|
||||||
|
# Note: This requires redefining the entire protocol block and may override
|
||||||
|
# other settings. Option 1 is simpler and less prone to conflicts.
|
||||||
|
# --------------------------------------------------------------------------
|
||||||
# LDAP example:
|
# LDAP example:
|
||||||
#passdb {
|
#passdb {
|
||||||
# args = /etc/dovecot/ldap/passdb.conf
|
# args = /etc/dovecot/ldap/passdb.conf
|
||||||
@@ -21,7 +40,7 @@ disable_plaintext_auth = yes
|
|||||||
login_log_format_elements = "user=<%u> method=%m rip=%r lip=%l mpid=%e %c %k"
|
login_log_format_elements = "user=<%u> method=%m rip=%r lip=%l mpid=%e %c %k"
|
||||||
mail_home = /var/vmail/%d/%n
|
mail_home = /var/vmail/%d/%n
|
||||||
mail_location = maildir:~/
|
mail_location = maildir:~/
|
||||||
mail_plugins = </etc/dovecot/mail_plugins
|
mail_plugins = </etc/dovecot/mail_plugins </etc/dovecot/mail_plugins_extra
|
||||||
mail_attachment_fs = crypt:set_prefix=mail_crypt_global:posix:
|
mail_attachment_fs = crypt:set_prefix=mail_crypt_global:posix:
|
||||||
mail_attachment_dir = /var/attachments
|
mail_attachment_dir = /var/attachments
|
||||||
mail_attachment_min_size = 128k
|
mail_attachment_min_size = 128k
|
||||||
@@ -180,12 +199,12 @@ userdb {
|
|||||||
skip = found
|
skip = found
|
||||||
}
|
}
|
||||||
protocol imap {
|
protocol imap {
|
||||||
mail_plugins = </etc/dovecot/mail_plugins_imap
|
mail_plugins = </etc/dovecot/mail_plugins_imap </etc/dovecot/mail_plugins_imap_extra
|
||||||
imap_metadata = yes
|
imap_metadata = yes
|
||||||
}
|
}
|
||||||
mail_attribute_dict = file:%h/dovecot-attributes
|
mail_attribute_dict = file:%h/dovecot-attributes
|
||||||
protocol lmtp {
|
protocol lmtp {
|
||||||
mail_plugins = </etc/dovecot/mail_plugins_lmtp
|
mail_plugins = </etc/dovecot/mail_plugins_lmtp </etc/dovecot/mail_plugins_lmtp_extra
|
||||||
auth_socket_path = /var/run/dovecot/auth-master
|
auth_socket_path = /var/run/dovecot/auth-master
|
||||||
}
|
}
|
||||||
protocol sieve {
|
protocol sieve {
|
||||||
|
|||||||
@@ -1,4 +1,3 @@
|
|||||||
{%- if env.SKIP_CLAMD == "n" or env.SKIP_CLAMD == "no" -%}
|
|
||||||
clamav {
|
clamav {
|
||||||
# Scan whole message
|
# Scan whole message
|
||||||
scan_mime_parts = false;
|
scan_mime_parts = false;
|
||||||
@@ -10,4 +9,3 @@ clamav {
|
|||||||
servers = "clamd:3310";
|
servers = "clamd:3310";
|
||||||
max_size = 20971520;
|
max_size = 20971520;
|
||||||
}
|
}
|
||||||
{% endif %}
|
|
||||||
|
|||||||
@@ -129,16 +129,7 @@ if (isset($_SESSION['mailcow_cc_role']) && ($_SESSION['mailcow_cc_role'] == "adm
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check if domain is an alias domain and get target domain's MTA-STS
|
$mta_sts = mailbox('get', 'mta_sts', $domain);
|
||||||
$alias_domain_details = mailbox('get', 'alias_domain_details', $domain);
|
|
||||||
$mta_sts_domain = $domain;
|
|
||||||
|
|
||||||
if ($alias_domain_details !== false && !empty($alias_domain_details['target_domain'])) {
|
|
||||||
// This is an alias domain, check target domain for MTA-STS
|
|
||||||
$mta_sts_domain = $alias_domain_details['target_domain'];
|
|
||||||
}
|
|
||||||
|
|
||||||
$mta_sts = mailbox('get', 'mta_sts', $mta_sts_domain);
|
|
||||||
if (count($mta_sts) > 0 && $mta_sts['active'] == 1) {
|
if (count($mta_sts) > 0 && $mta_sts['active'] == 1) {
|
||||||
if (!in_array($domain, $alias_domains)) {
|
if (!in_array($domain, $alias_domains)) {
|
||||||
$records[] = array(
|
$records[] = array(
|
||||||
|
|||||||
+1
-24
@@ -7,30 +7,7 @@ if (!isset($_SERVER['HTTP_HOST']) || strpos($_SERVER['HTTP_HOST'], 'mta-sts.') !
|
|||||||
}
|
}
|
||||||
|
|
||||||
$host = preg_replace('/:[0-9]+$/', '', $_SERVER['HTTP_HOST']);
|
$host = preg_replace('/:[0-9]+$/', '', $_SERVER['HTTP_HOST']);
|
||||||
$domain = idn_to_ascii(strtolower(str_replace('mta-sts.', '', $host)), 0, INTL_IDNA_VARIANT_UTS46);
|
$domain = str_replace('mta-sts.', '', $host);
|
||||||
|
|
||||||
// Validate domain or return 404 on error
|
|
||||||
if ($domain === false || empty($domain)) {
|
|
||||||
http_response_code(404);
|
|
||||||
exit;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Check if domain is an alias domain and resolve to target domain
|
|
||||||
try {
|
|
||||||
$stmt = $pdo->prepare("SELECT `target_domain` FROM `alias_domain` WHERE `alias_domain` = :domain");
|
|
||||||
$stmt->execute(array(':domain' => $domain));
|
|
||||||
$alias_row = $stmt->fetch(PDO::FETCH_ASSOC);
|
|
||||||
|
|
||||||
if ($alias_row !== false && !empty($alias_row['target_domain'])) {
|
|
||||||
// This is an alias domain, use the target domain for MTA-STS lookup
|
|
||||||
$domain = $alias_row['target_domain'];
|
|
||||||
}
|
|
||||||
} catch (PDOException $e) {
|
|
||||||
// On database error, return 404
|
|
||||||
http_response_code(404);
|
|
||||||
exit;
|
|
||||||
}
|
|
||||||
|
|
||||||
$mta_sts = mailbox('get', 'mta_sts', $domain);
|
$mta_sts = mailbox('get', 'mta_sts', $domain);
|
||||||
|
|
||||||
if (count($mta_sts) == 0 ||
|
if (count($mta_sts) == 0 ||
|
||||||
|
|||||||
+1
-2
@@ -97,7 +97,6 @@ services:
|
|||||||
- REDIS_SLAVEOF_PORT=${REDIS_SLAVEOF_PORT:-}
|
- REDIS_SLAVEOF_PORT=${REDIS_SLAVEOF_PORT:-}
|
||||||
- REDISPASS=${REDISPASS}
|
- REDISPASS=${REDISPASS}
|
||||||
- SPAMHAUS_DQS_KEY=${SPAMHAUS_DQS_KEY:-}
|
- SPAMHAUS_DQS_KEY=${SPAMHAUS_DQS_KEY:-}
|
||||||
- RSPAMD_SKIP_CLAMD=${SKIP_CLAMD:-n}
|
|
||||||
volumes:
|
volumes:
|
||||||
- ./data/hooks/rspamd:/hooks:Z
|
- ./data/hooks/rspamd:/hooks:Z
|
||||||
- ./data/conf/rspamd/custom/:/etc/rspamd/custom:z
|
- ./data/conf/rspamd/custom/:/etc/rspamd/custom:z
|
||||||
@@ -466,7 +465,7 @@ services:
|
|||||||
condition: service_started
|
condition: service_started
|
||||||
unbound-mailcow:
|
unbound-mailcow:
|
||||||
condition: service_healthy
|
condition: service_healthy
|
||||||
image: ghcr.io/mailcow/acme:1.95
|
image: ghcr.io/mailcow/acme:1.94
|
||||||
dns:
|
dns:
|
||||||
- ${IPV4_NETWORK:-172.22.1}.254
|
- ${IPV4_NETWORK:-172.22.1}.254
|
||||||
environment:
|
environment:
|
||||||
|
|||||||
Reference in New Issue
Block a user