mail's advanced junk settings NOT working

so I got a ton of junk mail, wanted to use the advanced filter settings to send a bunch of messages with same sender name directly to trash... NOT WORKING.


using the "From" field - first did "contains," and then also tried "is equal to" - inputting the various sender names (what show up in mail - not the email addresses themselves, as am pretty sure those change every time). doesn't work as keep receiving emails from sender names already on the list.


So... any ideas on how to actually get this working???


Posted on Jun 19, 2021 7:03 PM

Reply
Question marked as Top-ranking reply

Posted on Jun 20, 2021 9:59 AM

People sending you junk/spam emails continuously change the From name and email address to circumvent junk mail handling. I use a header field that Apple has not provided in the menu that you obtain the From header for your rule.


At the bottom of that same menu that you select the From header, is an Edit Header List… entry. Select that, and a panel appears that allows you to add [+] the new message header string Return-Path. Do that…



Click Ok. Back in the list of messages that you received, select one that is obviously junk/spam, and then add a new entry to your existing rules:



When you select Return-Path and contains, the field at the right will automatically populate with the Return-Path header string for the Mail server that sent the junk/spam email to you. They can change their name and their email server name in the From: message header all day long but if they go through the Mail server at that specific Return-Path account, you've got them. Then your action would be to move the message to mailbox Trash.


Once you click OK to save your rule, a dialog will pop asking if you want to apply the rules to the currently selected email. When you do, it is whacked into Trash, and your new rule is active for subsequent emails using that Return-Path server account.

9 replies
Question marked as Top-ranking reply

Jun 20, 2021 9:59 AM in response to sivante

People sending you junk/spam emails continuously change the From name and email address to circumvent junk mail handling. I use a header field that Apple has not provided in the menu that you obtain the From header for your rule.


At the bottom of that same menu that you select the From header, is an Edit Header List… entry. Select that, and a panel appears that allows you to add [+] the new message header string Return-Path. Do that…



Click Ok. Back in the list of messages that you received, select one that is obviously junk/spam, and then add a new entry to your existing rules:



When you select Return-Path and contains, the field at the right will automatically populate with the Return-Path header string for the Mail server that sent the junk/spam email to you. They can change their name and their email server name in the From: message header all day long but if they go through the Mail server at that specific Return-Path account, you've got them. Then your action would be to move the message to mailbox Trash.


Once you click OK to save your rule, a dialog will pop asking if you want to apply the rules to the currently selected email. When you do, it is whacked into Trash, and your new rule is active for subsequent emails using that Return-Path server account.

Jun 20, 2021 1:25 PM in response to sivante

Just understand that a spammer may have multiple accounts set up with a Return-Path Mail server and they may rotate these, so one Return-Path account might contain <bounce-10059985... and another might be <bounce=... I was able to consolidate fewer Return-Path rules by observing these patterns and changing contains to begins with <bounce-, <bound=, etc.).


Since legitimate senders of email may also use a Return-Path server account that begins with <bounce-… etc, one must be careful about sending these all to Trash until you are certain not to whack valid emails.


Here's an AppleScript that I run, one selected email at a time, to show me the From email address and the Return-Path address in a dialog:


use framework "Foundation"
use AppleScript version "2.4" -- Yosemite or later
use scripting additions

property NSString : a reference to current application's NSString
property NSRegularExpression : a reference to current application's NSRegularExpression
property NSRegularExpressionCaseInsensitive : a reference to current application's NSRegularExpressionCaseInsensitive

tell application "Mail"
	if not it is running then activate
	
	if not (get selection) is {} then
		set theMsg to item 1 of (get selection)
	else
		return
	end if
	
	tell theMsg
		set theSender to its sender
		set theHDR to its all headers
	end tell
end tell
set rtnpath to my return_address(theHDR) as text
set fmsg to "Sender Address:" & return & theSender & return & return & ¬
	"Return-Path:" & return & rtnpath

display dialog fmsg with title "Current Mail Item Addresses"
return

on return_address(atxt)
	set hstr to NSString's alloc()'s initWithString:atxt
	set pattern to "(?<=Return-Path:|Return-path:)\\s+(<.*?>).*"
	set regex to NSRegularExpression's regularExpressionWithPattern:pattern options:NSRegularExpressionCaseInsensitive |error|:0
	set hrange to current application's NSMakeRange(0, hstr's |length|())
	set matches to (regex's firstMatchInString:hstr options:0 range:hrange)
	
	if matches = "" then return "Not Found"
	
	set matchrange to matches's rangeAtIndex:1
	return (hstr's substringWithRange:matchrange) as text
end return_address


Jun 23, 2021 1:29 PM in response to sivante

The Return-Path only works as long as the spammers don't have several accounts on several Return-Path servers and rotate amongst them with entirely different From header content. In that scenario, you would continue to receive crap until you accounted for all of their Return-Path server accounts, which are also being added and removed by the spammers, or the owners of those servers.


Until this Spring, I was managing several spammers with just a few Return-Path rules, but now it has exploded, and I find they are using new servers, or different Return-Path accounts, and it is constant maintenance in Mail rules.


The script that I posted is copy/pasted into Apple's Script Editor (Launchpad > Other > Script Editor). Select a single email message, and then run the script in the Script Editor. A dialog will appear showing the From and Return-Path header strings.


There is no need to copy/paste the Return-Path from the above dialog into the Rules as once you add a new Return-Path rule and choose contains, the Return-Path header string will be automatically inserted for you in that rule.

Jun 23, 2021 12:39 PM in response to VikingOSX

ok, so simply trying the "Return-Path" trick did NOT work, as I'm still getting slammed with the junk.


curious about the script trick, though don't know that much technical detail...


exactly how/where would I run the script?


I'd just copy and paste - and then when it produced the return-path address, plug it into the rules with the "Return-Path" condition to aim it to the trash?


This thread has been closed by the system or the community team. You may vote for any posts you find helpful, or search the Community for additional answers.

mail's advanced junk settings NOT working

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple Account.