mailcow / mailcow-dockerized

mailcow: dockerized - 🐮 + 🐋 = 💕
https://mailcow.email
GNU General Public License v3.0
8.73k stars 1.17k forks source link

Flag external email #6084

Open kvdb opened 1 week ago

kvdb commented 1 week ago

Summary

Feature request

I would like to be able to enable the feature of flagging external email on a per-domain basis from the mailcow email configuration graphical interface.

Motivation

I manage a mailcow installations for a few coworker accounts. Not all of them are experienced internet users so I've been looking for a way to flag external mails. So far, people checked personally on requests to transfer money to a scammer on the Internet. (https://www.kaspersky.com/blog/how-to-spot-and-prevent-boss-scams/50861/)

Exisiting solutions

Microsoft users have had this feature for a long time already

Also, another helpful mailcow user wrote a script for this. However, I don't feel comfortable pasting forum scripts in my rspamd config that have not been code-reviewed by a core developer.

Additional context

No response

mac-linux-free commented 1 week ago

That is a great idea.

apio-sys commented 5 days ago

Microsoft users have had this feature for a [long time already

That isn't really a reason... Microsoft doesn't filter DMARC rejects by default, so should we also do such things? Of course not IMHO.

The idea for the banner or subject flag is very good though. And I think you can easily do this with the Global sieve filter mechanism in place. Discussion on that topic here: https://community.mailcow.email/d/3185-email-caution-text/2 comes up with some good ideas. If you change the proposed Zimbra script a bit to say something like:

require["editheader"];
require["variables"];

# add an external domain header to all email not coming from our own domains
if allof(
  not address :domain :is ["from"] ["mydomain.com"],
  not header :contains "Subject" ["[External Email]"]
)
{
  addheader "X-External-Domain" "This Message originated outside of mind.";
  # Match the entire subject ...
  if header :matches "Subject" "*" {
     # ... to get it in a match group that can then be stored in a variable:
     set "subject" "${1}";
  }

  # We can't "replace" a header, but we can delete (all instances of) it and
  # re-add (a single instance of) it:
  deleteheader "Subject";
  # Append/prepend as you see fit
  addheader :last "Subject" "[External Email] ${subject}";
  # Note that the header is added ":last" (so it won't appear before possible
  # "Received" headers).

}

and save it as a pre-filter it will work to change the subject line. You can/should amend whatever is needed for your organization of course.