Help with code to bounce emails

I am trying to set up Apple Mail to bounce emails that I don't want and send the error message back to sender.


This seems devilishly hard to do, and I found instructions online but they're not working. Thought maybe someone in the community would have an idea of what is not working about the code, here.


PASTED IN INSTRUCTIONS


If you want to get your Bounce back, whatever the reason, here’s how to do it – step by step:-

  1. Run the Automator program, located in your Applications folder.
  2. Click ‘New Document’ button.
  3. Select ‘Quick Action’ as document type then click the ‘Choose’ button. You’ll now have a window that you can drag and drop various actions in to.
  4. In left most pane, Select ‘Mail’, then in pane to right, select ‘Get Selected Mail Items’ (see screenshot 1).
  5. In the main editor’s ‘Workflow receives’ drop down menu at the top, select ‘no input’.
  6. Drag ‘Get Selected Mail Items’ Items to the right into the main editor window.
  7. In left most pane Select ‘Utilities’, then in pane to right select ‘Run AppleScript’ then drag ‘Run AppleScript’ into the editor window (see screenshot 2).
  8. Copy and paste the AppleScript code below into the ‘Run AppleScript’ editor (replacing all the default code) and save the workflow with a meaningful name such as, ‘Bounce Email’ (see screenshot 3).

The code to copy and paste:

on run {input, parameters}
     tell application "Mail"
         repeat with msg in input
             bounce msg
             delete msg
         end repeat
     end tell
 end run

When you’re in Apple Mail, you can now select a message that you want to Bounce i.e. from the ‘Mail’ menu, select ‘Services’ and then ‘Bounce Email’. The simplest way to check this out is to send yourself an email and to bounce it back to yourself.

Posted on Mar 24, 2021 12:24 AM

Reply

Similar questions

9 replies

Mar 24, 2021 5:11 AM in response to berlindavedsg

The From and Reply-To Mail header fields are not the real mail server address being used by legitimate and SPAM email originators, and the real Mail servers are in send-only mode. They are also likely programmed to accept only server-to-server communications in the event that your ISP's Mail server sends back an undeliverable error message. Any other reply attempts are either ignored entirely or may be processed to verify/augment the sending list of addresses.


This is likely the reason that Apple removed an actual bounce feature that was in Apple Mail nearly a decade ago.

Mar 24, 2021 1:58 AM in response to berlindavedsg

Bouncing email back to sender, even if achievable, serves not purpose other than to clog up the network with emails coming and going. Added, it does not deter the Spam Mailers one bit and only validates the email address is active and a real address. It might be better to just create a Rule to mark as Junk and automatically move to Junk Folder.

Mar 24, 2021 6:09 AM in response to berlindavedsg

If the sender is a private individual, they probably do not have a paid, dedicated commercial Mail server account, but just their own ISP Mail server. They would likely see your "bounce" email but as it did not originate from your Mail server as an undeliverable error, they may choose to ignore or honor it. Just as clicking an unsubscribe link may or may not be honored by the sender, but most often, simply confirming they have your valid email address.


However, some legitimate senders that deal in large volumes of email will likely pay for a unique, commercial mail server account, the same as some Spammers do. I used to receive upwards of 30 SPAM emails a day until I created four rules in Apple Mail that check the first few common character pattern of the Return-Path header string of those emails. However, in practice, Affinity is now sending newsletters that I actually want to receive in my inbox, but they are also using the same first few character pattern that is the same as the Spammers, so I have to make an adjustment to my pattern matching rules to preserve the Affinity communications.

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.

Help with code to bounce emails

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