public
nobgit
read
NobMail
Based on mailcow: dockerized
Languages
Repository composition by tracked source files.
PHP
49%
JavaScript
35%
HTML
9%
CSS
4%
Shell
2%
Python
1%
Lua
0%
Perl
0%
Ruby
0%
SCSS
0%
Create file
Wiki Documentation
Clone
https://nobgit.com/orgs/nobgit/nobmail.git
ssh://[email protected]:2222/orgs/nobgit/nobmail.git
Commit
[Rspamd] Enhance SOGo contacts dynmap (#4245)
* [Rspamd] Fix SOGo Contacts Dynmap 1. Lowercase all emails to align with Rspamd 2. Remove dots from gmail.com and change googlemail.com to gmail.com to align with Rspamd per https://github.com/rspamd/rspamd/blob/master/lualib/lua_util.lua#L271-L274 * Update settings.php Fix case when gmail.com or google.com is stored in contact book not in lowercase * Update settings.php Add removing of Tags in emails as Rspamd not count them as part of From
a26bbff6
data/conf/rspamd/dynmaps/settings.php | 26 +++++++++++++++++++++++++-
1 file changed, 25 insertions(+), 1 deletion(-)
Diff
diff --git a/data/conf/rspamd/dynmaps/settings.php b/data/conf/rspamd/dynmaps/settings.php
index ddff7ff5..274e9da2 100644
--- a/data/conf/rspamd/dynmaps/settings.php
+++ b/data/conf/rspamd/dynmaps/settings.php
@@ -49,6 +49,30 @@ function parse_email($email) {
return array('local' => substr($email, 0, $a), 'domain' => substr($email, $a));
}
+function normalize_email($email) {
+ $email = strtolower(str_replace('/', '\/', $email));
+ $gm = "@gmail.com";
+ if (substr_compare($email, $gm, -strlen($gm)) == 0) {
+ $email = explode('@', $email);
+ $email[0] = str_replace('.', '', $email[0]);
+ $email = implode('@', $email);
+ }
+ $gm_alt = "@googlemail.com";
+ if (substr_compare($email, $gm_alt, -strlen($gm_alt)) == 0) {
+ $email = explode('@', $email);
+ $email[0] = str_replace('.', '', $email[0]);
+ $email[1] = str_replace('@', '', $gm);
+ $email = implode('@', $email);
+ }
+ if (str_contains($email, "+")) {
+ $email = explode('@', $email);
+ $user = explode('+', $email[0]);
+ $email[0] = $user[0];
+ $email = implode('@', $email);
+ }
+ return $email;
+}
+
function wl_by_sogo() {
global $pdo;
$rcpt = array();
@@ -63,7 +87,7 @@ function wl_by_sogo() {
}
// Explicit from, no mime_from, no regex - envelope must match
// mailcow white and blacklists also cover mime_from
- $rcpt[$row['user']][] = str_replace('/', '\/', $contact);
+ $rcpt[$row['user']][] = normalize_email($contact);
}
}
return $rcpt;