Keep the Junk folder consistent between iCloud Mail and macOS

If you use macOS Mail to check your iCloud email, your Junk folder's content might differ from what you see when you check your iCloud email from somewhere else. If so, use the following steps.

Here's how to keep the contents of both Junk folders the same between iCloud Mail and macOS Mail:

Open the Mail app on your Mac.

Choose Mail > Preferences.

Click Junk Mail, then select “Enable junk mail filtering” and “Move it to the Junk mailbox.”

Click Accounts.

Select your iCloud email account on the left.

Click Mailbox Behaviors, then click the menu next to Junk Mailbox. Under iCloud in the menu, choose Junk.

Now, all messages marked as junk are stored on the iCloud server and you can see them in the Junk folders of both macOS Mail and iCloud Mail. If you delete a message from either folder, you delete the message permanently.